UM 友盟分享gif 图片到 QQ 和 微信
- 浪费了一天的时间纠结在的分享的上面
- 检查你的友盟版本是否是最新的 (5.2.1分享没有问题)如果是低版本快点升级吧
- 仔细看下的微信 和 QQ 分享文档,对你使用友盟分享有很大的作用
NSData *shareImage = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://ww4.sinaimg.cn/large/006ngh3hjw1f1zn2ab4opg30a10a1461.gif"]];
[UMSocialData defaultData].extConfig.wechatSessionData.url = @"http://ww4.sinaimg.cn/large/006ngh3hjw1f1zn2ab4opg30a10a1461.gif";
[UMSocialData defaultData].extConfig.wechatSessionData.wxMessageType = UMSocialWXMessageTypeEmotion;
//微信朋友分享
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatSession] content:nil image:shareImage location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response) {
if (response.responseCode == UMSResponseCodeSuccess) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"成功" message:@"分享成功" delegate:nil cancelButtonTitle:@"好" otherButtonTitles: nil];
[alertView show];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"抱歉" message:@"分享失败" delegate:nil cancelButtonTitle:@"好" otherButtonTitles: nil];
[alertView show];
}
}];
QQ好友分享
// QQ 好友分享
NSData *shareImage = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://ww4.sinaimg.cn/large/006ngh3hjw1f1zn2ab4opg30a10a1461.gif"]];
UMSocialUrlResource *urlSource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeImage url:@"http://ww4.sinaimg.cn/large/006ngh3hjw1f1zn2ab4opg30a10a1461.gif"];
[UMSocialData defaultData].extConfig.qqData.url = @"http://ww4.sinaimg.cn/large/006ngh3hjw1f1zn2ab4opg30a10a1461.gif";
[UMSocialData defaultData].extConfig.qqData.qqMessageType = UMSocialQQMessageTypeImage;
//这里你可以把分享平台UMShareToSina换成其他平台
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToQQ] content:nil image:shareImage location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response) {
if (response.responseCode == UMSResponseCodeSuccess) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"成功" message:@"分享成功" delegate:nil cancelButtonTitle:@"好" otherButtonTitles: nil];
[alertView show];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"抱歉" message:@"分享失败" delegate:nil cancelButtonTitle:@"好" otherButtonTitles: nil];
[alertView show];
}
}];