美文网首页
iOS 微信分享小程序 记录

iOS 微信分享小程序 记录

作者: UILable攻城狮 | 来源:发表于2023-08-15 10:45 被阅读0次

使用WXApi 分享

[WXApi registerApp:@"wxid" universalLink:@"https://xxxxxxx"];
        WXMiniProgramObject *wxMiniobject = [[WXMiniProgramObject alloc]init];
    //    wxMiniprogramobject *wxMiniobject=IwxMiniprogramobjiectobject];
        wxMiniobject.webpageUrl = @"http://www.qq.com";
    //    //莱容低版本的网页链按
        wxMiniobject.userName = @"xxxxxxx";
    //    //小程序的原始id
        wxMiniobject.path = @"/pages/index/index";
    //    //小程序页面的路径
    //    wxMiniObject.hdImageData = hdImageData;
    //    //小程序节点高洁大图,小于128k
        WXMediaMessage *message = [WXMediaMessage message];
    //    message•tit1日=四"小程序tit1e";
        message.description=@"小程序desc";
        message.mediaObject = wxMiniobject;
    //    message.thumbData=nil;//辣容日版本节点的國片,小于32k,新版本优先
    //    //使用wxMiniProgramobject的hdImageData屭性
        SendMessageToWXReq *req1 = [[SendMessageToWXReq alloc] init];
        req1.message = message;
        req1.scene=WXSceneSession;//日前只支持会话
        [WXApi sendReq:req1 completion:^(BOOL success) {
    
        }];

使用ShareSDK 分享小程序

 NSMutableDictionary *dicM = [NSMutableDictionary dictionary];
    [dicM SSDKSetupWeChatMiniProgramShareParamsByTitle:@""
                                           description:@""
                                            webpageUrl:[NSURL URLWithString:@"http://www.qq.com"]
                                                  path:@"/pages/index/index"
                                            thumbImage:@""
                                          hdThumbImage:@""
                                              userName:@"xxxx"
                                       withShareTicket:YES
                                       miniProgramType:0
                                    forPlatformSubType:SSDKPlatformSubTypeWechatSession];
    
    [ShareSDK share:SSDKPlatformSubTypeWechatSession parameters:dicM onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
      
        if (state == SSDKResponseStateSuccess ){
           
            if (sucessHandler) {
                sucessHandler(YES);
            }
        }else{
            if (sucessHandler) {
                sucessHandler(NO);
            }
        }
    }];

相关文章

网友评论

      本文标题:iOS 微信分享小程序 记录

      本文链接:https://www.haomeiwen.com/subject/uprhmdtx.html