- iOS第三方app可以打开小程序,但是不能分享小程序?
我在从调用iOS打开小程序时,可以打开,但是分享小程序的时候却提示“应用和小程序未绑定在同一微信开放平台账号” 分享的时候,会跳转两次,第一次如图,并且代码的success返回也是YES [代码][WXApi sendReq:req completion:^([代码][代码]BOOL[代码] [代码]success) {[代码][代码] [代码][代码]completion(success);[代码][代码] [代码][代码]}];[代码][图片] 但实际上是已经绑定在同一个账号下了 提示如下图: [图片] 背景如下: app是有关联小程序的,也执行过WXApi 下面这个方法了; + (BOOL)registerApp:(NSString *)appid universalLink:(NSString *)universalLink; 小程序只发布了体验版,正式版尚未发布; 分享小程序的时候代码如下: [代码]/// 分享微信小程序[代码][代码]+ ([代码][代码]void[代码][代码])shareMiniProgramWithTitle:(NSString *)title[代码][代码] [代码][代码]hdImage:(UIImage *)hdImage[代码][代码] [代码][代码]userName:(NSString *)userName[代码][代码] [代码][代码]webpageUrl:(NSString *)webpageUrl[代码][代码] [代码][代码]path:(NSString *)path[代码][代码] [代码][代码]miniProgramType:(WXMiniProgramType)type[代码][代码] [代码][代码]completion:([代码][代码]void[代码] [代码](^ __nullable)([代码][代码]BOOL[代码] [代码]success))completion {[代码][代码] [代码][代码]WXMiniProgramObject *object = [WXMiniProgramObject object];[代码][代码] [代码][代码]object.webpageUrl = webpageUrl;[代码][代码] [代码][代码]object.userName = userName;[代码][代码] [代码][代码]object.path = path;[代码][代码] [代码][代码]NSData * imageData = UIImageJPEGRepresentation(hdImage, 0.7);[代码][代码] [代码][代码]object.hdImageData = imageData;[代码][代码] [代码][代码]object.withShareTicket = YES;[代码][代码] [代码][代码]object.miniProgramType = type;[代码][代码] [代码][代码]WXMediaMessage *message = [WXMediaMessage message];[代码][代码] [代码][代码]message.title = title;[代码][代码] [代码][代码]message.description = @[代码][代码]"山证工作室"[代码][代码];[代码][代码] [代码][代码]message.thumbData = nil;[代码][代码] [代码][代码]//兼容旧版本节点的图片,小于32KB,新版本优先[代码][代码] [代码][代码]//使用WXMiniProgramObject的hdImageData属性[代码][代码] [代码][代码]message.mediaObject = object;[代码][代码] [代码][代码]SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];[代码][代码] [代码][代码]req.bText = NO;[代码][代码] [代码][代码]req.message = message;[代码][代码] [代码][代码]req.scene = WXSceneSession; [代码][代码]//目前只支持会话[代码][代码] [代码][代码][WXApi sendReq:req completion:^([代码][代码]BOOL[代码] [代码]success) {[代码][代码] [代码][代码]completion(success);[代码][代码] [代码][代码]}];[代码][代码]}[代码]打开小程序代码如下: [代码]/// 打开微信小程序[代码][代码]+ ([代码][代码]void[代码][代码])openMiniProgramWithUserName:(NSString *)userName[代码][代码] [代码][代码]Path:(NSString *)path[代码][代码] [代码][代码]miniProgramType:(WXMiniProgramType)type[代码][代码] [代码][代码]completion:([代码][代码]void[代码] [代码](^ __nullable)([代码][代码]BOOL[代码] [代码]success))completion {[代码][代码] [代码][代码]WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];[代码][代码] [代码][代码]launchMiniProgramReq.userName = userName; [代码][代码]//拉起的小程序的username[代码][代码] [代码][代码]launchMiniProgramReq.path = path; [代码][代码]//拉起小程序页面的可带参路径,不填默认拉起小程序首页,对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。[代码][代码] [代码][代码]launchMiniProgramReq.miniProgramType = type; [代码][代码]//拉起小程序的类型[代码][代码] [代码][代码][WXApi sendReq:launchMiniProgramReq completion:^([代码][代码]BOOL[代码] [代码]success) {[代码][代码] [代码][代码]completion(success);[代码][代码] [代码][代码]}];[代码][代码]}[代码]
2019-12-07 - iOS分享图片及小程序问题,为何分享图片的时候也会关联小程序?
我在从iOS分享图片到小程序的时候,会跳转两次。第一次是链接小程序的界面(如图),load结束后会跳回App,然后又自动跳回微信才是成功的分享图片界面,请问是什么情况? [图片] 背景如下: app是有关联小程序的,也执行过WXApi 下面这个方法了; + (BOOL)registerApp:(NSString *)appid universalLink:(NSString *)universalLink; 小程序只发布了体验版,正式版尚未发布; 分享图片的时候代码如下: [代码]+ ([代码][代码]void[代码][代码])shareImageWithWeChatWithType:([代码][代码]int[代码][代码])scene[代码][代码] [代码][代码]image:(UIImage *)image[代码][代码] [代码][代码]completion:([代码][代码]void[代码] [代码](^ __nullable)([代码][代码]BOOL[代码] [代码]success))completion {[代码][代码] [代码][代码]if[代码] [代码]([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi]) {[代码][代码] [代码][代码]// 压缩图片小于10M[代码][代码] [代码][代码]NSData * imageData = UIImageJPEGRepresentation([SZUtils compressImage:image toByte:10485760], 0.7);[代码][代码] [代码][代码]WXImageObject *imageObject = [WXImageObject object];[代码][代码] [代码][代码]imageObject.imageData = imageData;[代码][代码] [代码][代码]WXMediaMessage *message = [WXMediaMessage message];[代码][代码] [代码][代码]// 压缩图片小于32kb[代码][代码] [代码][代码][message setThumbImage:[SZUtils compressImage:image toByte:32768]];[代码][代码] [代码][代码]message.mediaObject = imageObject;[代码][代码] [代码][代码]SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];[代码][代码] [代码][代码]req.bText = NO;[代码][代码] [代码][代码]req.message = message;[代码][代码] [代码][代码]req.scene = scene;[代码][代码] [代码][代码][WXApi sendReq:req completion:^([代码][代码]BOOL[代码] [代码]success){[代码][代码] [代码][代码]completion(success);[代码][代码] [代码][代码]}];[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码][SZUtils showAlert:@[代码][代码]"请安装微信"[代码] [代码]okBtn:@[代码][代码]"确定"[代码] [代码]result:^(NSInteger index) {[代码][代码] [代码] [代码] [代码][代码]}];[代码][代码] [代码][代码]}[代码][代码]}[代码]
2019-12-07