URL分享
1 | WXMediaMessage * message = [WXMediaMessage message]; |
分享小程序
1 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"shareMiniprogram" ofType:@"png"]; |
直接打开小程序
1 | WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object]; |
Image分享
1 | NSDictionary * dataDir = (NSDictionary*)data; |
ps: 几点注意
1.微信小程序分享图片不能超过32k 否则分享不出去
2.微信小程序分享图片必须是nsdata格式
1 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"shareMiniprogram" ofType:@"png"]; |
所以一定要这么取
ps:有时候图片拖进项目里会找不到图片这个时候需要选中图片之后选择菜单中的
Source Control —> add selected files 就加进去了
参考:微信开发者平台
ps: base64 转图片方法
NSString * img = [NSString stringWithFormat:@"%@", [dataDir objectForKey:@"img"]];
NSURL *url = [NSURL URLWithString:img];
NSData *imgData = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imgData];