iOS-友盟单个分享

分享URL链接

  1. 微信好友
[UMSocialData defaultData].extConfig.wechatSessionData.title = @"分享标题";
[UMSocialData defaultData].extConfig.wechatSessionData.url = @"分享链接";
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatSession] content:@"分享内容" image:[UIImage imageNamed:@"xxx"] location:nil urlResource:nil presentedController:nil completion:^(UMSocialResponseEntity *shareResponse){
    if (shareResponse.responseCode == UMSResponseCodeSuccess) {
        NSLog(@"分享成功!");
    }
}];
  1. 微信朋友圈
[UMSocialData defaultData].extConfig.wechatTimelineData.title = @"分享标题";
[UMSocialData defaultData].extConfig.wechatTimelineData.url = @"分享链接";
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToWechatTimeline] content:@"分享内容" image:[UIImage imageNamed:@"xxx"] location:nil urlResource:nil presentedController:nil completion:^(UMSocialResponseEntity *shareResponse){
    if (shareResponse.responseCode == UMSResponseCodeSuccess) {
        NSLog(@"分享成功!");
    }
}];
  1. QQ
[UMSocialData defaultData].extConfig.qqData.url = @"分享链接";
[UMSocialData defaultData].extConfig.qqData.title = @"分享标题";
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToQQ] content:@"分享内容" image:[UIImage imageNamed:@"xxx"] location:nil urlResource:nil presentedController:nil completion:^(UMSocialResponseEntity *shareResponse) {
    if (shareResponse.responseCode == UMSResponseCodeSuccess) {
        NSLog(@"分享成功!");
    }
}];
  1. QQ空间
[UMSocialData defaultData].extConfig.qzoneData.title = @"分享标题";
[UMSocialData defaultData].extConfig.qzoneData.url = @"分享链接";
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToQzone] content:@"分享内容" image:[UIImage imageNamed:@"xxx"] location:nil urlResource:nil presentedController:nil completion:^(UMSocialResponseEntity *shareResponse) {
    if (shareResponse.responseCode == UMSResponseCodeSuccess) {
        NSLog(@"分享成功!");
    }
}];
  1. 新浪微博
// 新浪微博分享比较特殊,直接把链接放到内容里面
NSString *shareContent = [@"分享内容" stringByAppendingString:@"分享链接"];
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToSina] content:shareContent image:[UIImage imageNamed:@"xxx"] location:nil urlResource:nil presentedController:nil completion:^(UMSocialResponseEntity *shareResponse) {
    if (shareResponse.responseCode == UMSResponseCodeSuccess) {
        NSLog(@"分享成功!");
    }
}];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容