分享至微博、QQ好友、微信好友、微信朋友圈
前期工作上一篇已完成,直接至分享页面
1、设置分享内容
[UMSocialQQHandler setQQWithAppId:UM_QQ_APPID appKey:UM_QQ_APPKEY url:_urlDic[@"qqurl"]];
[UMSocialData defaultData].extConfig.qqData.url = @"qqurl";
[UMSocialData defaultData].extConfig.qqData.title = @"title";
[UMSocialData defaultData].extConfig.wechatSessionData.wxMessageType = UMSocialWXMessageTypeWeb;
[UMSocialData defaultData].extConfig.wechatSessionData.title = @"title";
[UMSocialData defaultData].extConfig.wechatSessionData.url = @"wchaturl";
[UMSocialData defaultData].extConfig.wechatTimelineData.wxMessageType = UMSocialWXMessageTypeWeb;
[UMSocialData defaultData].extConfig.wechatTimelineData.title = @"title";
[UMSocialData defaultData].extConfig.wechatTimelineData.url = @"wchaturl";
2、调用友盟分享
[UMSocialConfig setSupportedInterfaceOrientations:UIInterfaceOrientationMaskPortrait]; // 支持分享编辑页和授权页面横屏
[UMSocialSnsService presentSnsIconSheetView:self
appKey:@"UMENG_APPID"
shareText:@"title"
shareImage:[UIImage imageNamed:@""]
shareToSnsNames:[NSArray arrayWithObjects:UMShareToWechatSession,UMShareToWechatTimeline,UMShareToQQ,UMShareToSina,nil]
delegate:self];
3、友盟分享界面弹出前调用
- (void)didSelectSocialPlatform:(NSString *)platformName withSocialData:(UMSocialData *)socialData{
NSString *order_share = _shareIntro;
NSString *order_sina_share_text = @"";
if (platformName == UMShareToSina) {
socialData.shareText = order_sina_share_text;
socialData.shareImage = [UIImage imageNamed:@""];
}
if (platformName == UMShareToWechatSession) {
socialData.shareText = order_share;
}
if (platformName == UMShareToWechatTimeline) {
}
if (platformName == UMShareToQQ) {
socialData.shareText = order_share;
}
}
4、分享成功回调
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response{
//根据 responseCode 得到发送结果,如果分享成功
if(response.responseCode == UMSResponseCodeSuccess)
{
// //获取成功分享平台名
// NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
}
}
PS:
1、微博分享内容直接 内容+url 分享成功以后长网址会自动缩减成短网址
2、url分享 需要带UIImage 否则分享的时候 没有封装成网址