UM 友盟分享gif 图片到 QQ 和 微信

UM 友盟分享gif 图片到 QQ 和 微信

  1. 浪费了一天的时间纠结在的分享的上面
  2. 检查你的友盟版本是否是最新的 (5.2.1分享没有问题)如果是低版本快点升级吧
  3. 仔细看下的微信 和 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];
 }
 }];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,138评论 25 709
  • 前言 友盟能实现分享功能,友盟+申请第三方账号的目的: 进行分享、授权操作需要在第三方平台创建应用并提交审核,友盟...
    CoderZb阅读 9,753评论 8 60
  • 有的事情不用当面对你说:有一个人,他总是把你放在心中,就像那看似平静的湖面,把高远的天空映入深邃的湖底,只要有一点...
    林嘉梓阅读 6,313评论 94 262
  • 认真地“读”准每一个字 昨天发生了文件误删事件,公众号里的文章编辑好之后,鼠标一点,就发布了。等发布之后才发现题目...
    六月_cef1阅读 706评论 0 1
  • joe45就是我 开始练习写作和演讲。 虽然大量阅读,但是不写点东西,永远只是一个读者,思考也难以深入,学习的效果...
    joe45阅读 155评论 0 0