Introduction: The company’s native APP has a block of functions that originally need to share small programs to wechat, now changed to share into the form of H5, carry parameters are not discussed, here to record.

The official document: developer.umeng.com/docs/128606…

Android share H5:developer.umeng.com/docs/128606…

IOS sharing H5:developer.umeng.com/docs/128606…

 

Supported styles

Before integrating umeng + U-share SDK, you first need to register on [Umeng +] official website and add new application to obtain Appkey.

Add permissions (add the following permissions in AndroidManifest)

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Copy the code

 

Enterprise wechat parameters need to log in the enterprise wechat management background work.weixin.qq.com/ to check. Set the following parameters: parameter 1: ID (my enterprise ID), parameter 2: Secret (Application management -> your application name Secret), parameter 3: AgentId (Application management -> your application name AgentId), and parameter 4: Schema (Application Management -> Enterprise wechat authorized login ->Android Schema)

        // Wechat Settings
        PlatformConfig.setWeixin("wxdc1e388c3822c80b"."3baf1193c85774b3fd9d18447d76cab0");
        PlatformConfig.setWXFileProvider("com.tencent.sample2.fileprovider");
        / / QQ Settings
        PlatformConfig.setQQZone("101830139"."5d63ae8858f1caab67715ccd6c18d7a5");
        PlatformConfig.setQQFileProvider("com.tencent.sample2.fileprovider");
        // Enterprise wechat Settings
        PlatformConfig.setWXWork("wwac6ffb259ff6f66a"."EU1LRsWC5uWn6KUuYOiWUpkoH45eOA0yH-ngL8579zs"."1000002"."wwauthac6ffb259ff6f66a000002");
        PlatformConfig.setWXWorkFileProvider("com.tencent.sample2.fileprovider");
        // Other platform Settings
        PlatformConfig.setSinaWeibo("3921700954"."04b48b094faeb16683c32669824ebdad"."http://sns.whalecloud.com");
        PlatformConfig.setDing("dingoalmlnohc0wggfedpk");
        PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
        PlatformConfig.setAlipay("2015111700822536");
        PlatformConfig.setLaiwang("laiwangd497e70d4"."d497e70d4c3e4efeab1381476bac4c5e");
        PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi"."MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
        PlatformConfig.setPinterest("1439206");
        PlatformConfig.setKakao("e4f60e065048eb031e235c806b31c70f");   
        PlatformConfig.setVKontakte("5764965"."5My6SNliAaLxEm3Lyd9J");
        PlatformConfig.setDropbox("oz8v5apet3arcdy"."h7p2pjbzkkxt02a");
        PlatformConfig.setYnote("9c82bf470cba7bd2f1819b0ee26f86c6ce670e9b");
Copy the code

Android Sharing Access

Sharing web links (Sharing web links can be shared using UMWeb)

UMWeb  web = new UMWeb(Defaultcontent.url);
        web.setTitle("This is music title");/ / title
        web.setThumb(thumb);  / / thumbnails
        web.setDescription("my description");/ / description
Copy the code

The call then sets this parameter to ShareAction

new ShareAction(ShareActivity.this)
    .withMedia(web)
    .share();
Copy the code

Share applets

The type of small program supports the sharing of micro channel applets and QQ applets, among which the micro channel applets can only be shared to wechat friends, circle of friends, and wechat collection. The following is the micro channel applets sharing code:

UMMin umMin = new UMMin(Defaultcontent.url);
// Compatible with lower versions of web links
umMin.setThumb(imagelocal);
// Applet message cover image
umMin.setTitle(Defaultcontent.title);
// Applet message title
umMin.setDescription(Defaultcontent.text);
// Applet message description
umMin.setPath("pages/page10007/xxxxxx");
// Applets page path
umMin.setUserName("gh_xxxxxxxxxxxx");
// Small program original ID, in wechat platform query
new ShareAction(ShareDetailActivity.this)
.withMedia(umMin)
.setPlatform(share_media)
.setCallback(shareListener).share();
Copy the code

The following is the QQ small program to share code:

// QQ applet share sample code, located in the official Demo project shareDetailActivity.java
public void shareQQMiniApp() {
        UMQQMini qqMini = new UMQQMini(Defaultcontent.url);
        qqMini.setThumb(new UMImage(this, Defaultcontent.imageurl)); // Thumbnails support both web and local images
        qqMini.setTitle(Defaultcontent.title);
        qqMini.setDescription(Defaultcontent.text);
        qqMini.setMiniAppId("1110429485");
        qqMini.setPath("pages/index/index");
        new ShareAction(ShareDetailActivity.this)
                .withMedia(qqMini)
                .setPlatform(share_media)
                .setCallback(shareListener).share();
    }
Copy the code

More access to refer to: developer.umeng.com/docs/128606…

IOS Sharing Access

Sharing web links

- (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType
{
    // Create a shared message object
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];

    // Create web content objects
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@" Share title" descr:@" Share content description" thumImage:[UIImage imageNamed:@"icon"]].// Set the page address
    shareObject.webpageUrl =@"http://mobile.umeng.com/social";

    // Share message object Sets the share content object
    messageObject.shareObject = shareObject;

    // Call the share interface
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            NSLog(@"************Share fail with error %@*********",error);
        }else{
            NSLog(@"response data is %@",data); }}]; }Copy the code

Share applets

Small program support to share to QQ and wechat two platforms

- (void)shareMiniProgramToPlatformType:(UMSocialPlatformType)platformType
{
    // Create a shared message object
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];

    UMShareMiniProgramObject *shareObject = [UMShareMiniProgramObject shareObjectWithTitle:@" Applet title" descr:@" Applets content description" thumImage:[UIImage imageNamed:@"icon"]];
    shareObject.webpageUrl = @" Compatible with wechat lower version webpage address";
    shareObject.userName = @" small program username, such as gh_3AC2059AC66f";
    shareObject.path = @ "small program page path, such as pages/page10007 page10007";
    messageObject.shareObject = shareObject;
    shareObject.hdImageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logo" ofType:@"png"]];
    shareObject.miniProgramType = UShareWXMiniProgramTypeRelease; // Experience and development boards are available

    // Call the share interface
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                // Share the result message
                UMSocialLogInfo(@"response message is %@",resp.message);
                // The data originally returned by the third party
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);

            }else{
                UMSocialLogInfo(@"response data is %@",data); }} [self alertWithError:error];
    }];
}
Copy the code

More ios sharing access please refer to: developer.umeng.com/docs/128606…

 

 

In addition, please refer to custom wechat sharing

H5 web WeChat share functions: www.jianshu.com/p/922b0986d…

How to use WeChat JSSDK custom sharing function: https://www.huceo.com/post/414.html