使用WXApi 分享
[WXApi registerApp:@"wxid" universalLink:@"https://xxxxxxx"];
WXMiniProgramObject *wxMiniobject = [[WXMiniProgramObject alloc]init];
// wxMiniprogramobject *wxMiniobject=IwxMiniprogramobjiectobject];
wxMiniobject.webpageUrl = @"http://www.qq.com";
// //萊容低版本的網(wǎng)頁鏈按
wxMiniobject.userName = @"xxxxxxx";
// //小程序的原始id
wxMiniobject.path = @"/pages/index/index";
// //小程序頁面的路徑
// wxMiniObject.hdImageData = hdImageData;
// //小程序節(jié)點(diǎn)高潔大圖怪嫌,小于128k
WXMediaMessage *message = [WXMediaMessage message];
// message?tit1日=四"小程序tit1e";
message.description=@"小程序desc";
message.mediaObject = wxMiniobject;
// message.thumbData=nil;//辣容日版本節(jié)點(diǎn)的國片,小于32k柳沙,新版本優(yōu)先
// //使用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);
}
}
}];