友盟SDK应用(二)------url分享

分享至微博、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 否则分享的时候 没有封装成网址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值