iOS sharing applet

Recently, the emergence of mini programs has really exploded, causing discussion groups to be bombarded in turn, so how to share WeChat mini programs?

Preliminary preparation:

First of all, we must understand that the WeChat account and the account of the applet developed by iOS are not allowed to be the same WeChat account. However, we can find it on the WeChat open platform.

Wood is wrong! It is possible to bind the applet, and there are currently 5 different themes online, 5 times a month, the same subject, 50 online, and there is no limit to the number of times, then we click to bind the applet:

Then follow the process~~~ Go on and the successful binding will be displayed here: (Verification of these requires a small program account, for specific emmmmm, you can ask your applet developer for an account)

Click to view to see some information about the applet:

Remember these IDs, you will need them later

Open our Xcode, if you have access to WeChat payment or Umeng sharing or shareSDK, many steps will be omitted here, if you have not accessed, emmmm,,,, go to apply for a key first~

like this

After the application, it is best to write it in the form of a macro to facilitate future modification. The shareSDK used for the project I took over here

but! The implementation is the same, but remember one thing! ! ! Remember to watch it! Look good! Look good! If you have access to WeChat Pay and use third-party social sharing ( knock on the blackboard: Umeng sharing or shareSDK ), you must see clearly whether you are importing a package with or without payment! Remember remember! Repeat the import, whoever leads who knows (can't tune up WeChat)!

Because I am using shareSDK here, the following part focuses on the way of using shareSDK, but it is similar, the key is parameter configuration

 

We see this method in shareSDK:

/**
 v4.0.7 为微信小程序分享增加
 
 @param title 标题
 @param description 详细说明
 @param webpageUrl 网址(6.5.6以下版本微信会自动转化为分享链接 必填)
 @param path 跳转到页面路径
 @param thumbImage 缩略图 (必填)
 @param userName 小程序的userName (必填)
 @param withShareTicket 是否使用带 shareTicket 的转发
 @param type 分享小程序的版本(0-正式,1-开发,2-体验)
 @param platformSubType 分享自平台 微信小程序暂只支持 SSDKPlatformSubTypeWechatSession(微信好友分享)
 */
- (void)SSDKSetupWeChatMiniProgramShareParamsByTitle:(NSString *)title
                                         description:(NSString *)description
                                          webpageUrl:(NSURL *)webpageUrl
                                                path:(NSString *)path
                                          thumbImage:(id)thumbImage
                                            userName:(NSString *)userName
                                     withShareTicket:(BOOL)withShareTicket
                                     miniProgramType:(NSUInteger)type
                                  forPlatformSubType:(SSDKPlatformType)platformSubType;

This method is a small program method for calling WeChat and sharing. The parameter configuration is basically the same as using WeChat directly. It should be noted that:

Here userName needs to fill in the original ID of the applet! That is gh_XXXXX that!

The url and path must also be written correctly. You can ask the colleague of the applet. Generally, the url is your environment, and the path is generally "pages/.../..."

It is worth noting that the default image thumbImage (that is, the part that occupies the most) shared by the applet can be specified by you. This image will be compressed by WeChat, so the size of the image that can be provided is relatively large.

 

{
    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    //平台定制
    
    [parameters SSDKSetupWeChatMiniProgramShareParamsByTitle:title
                                                 description:text
                                                  webpageUrl:[NSURL URLWithString:url]
                                                        path:path
                                                  thumbImage:thumbImage
                                                    userName:APP_SmallProgram
                                             withShareTicket:YES
                                             miniProgramType:0
                                          forPlatformSubType:SSDKPlatformSubTypeWechatSession];
    
    [ShareSDK share:SSDKPlatformSubTypeWechatSession
         parameters:parameters
     onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
         if(state == SSDKResponseStateBeginUPLoad){
             return ;
         }
        
         switch (state) {
             case SSDKResponseStateSuccess:
             {
                 NSLog(@"分享成功");
                 break;
             }
             case SSDKResponseStateFail:
             {
                 NSLog(@"error :%@",error);
                 break;
             }
             case SSDKResponseStateCancel:
             {
                 break;
             }
             default:
                 break;
         }
         
     }];
    
}

In this way, you can share the applet with the APP, like this

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325346834&siteId=291194637