2016友盟分享 iOS10 更新后使用

开始的通用配置我就不简述了 大家看官网http://dev.umeng.com/social/ios/quick-integration 看到3.2 就可以了。

重点 如果让显示分享框的话 一定要注意 mainStoryboard 和你自己重新定义的window即 self.window=[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 只能保留一个!!! 建议就是点击mainStoryboard把根视图 换成你自定义的rootViewController (当然你也可以删除了 Main Interface 即:mainStoryboard) 任选其一,否则不会弹出分享选择框,以下步骤也就不会奏效

  1. 如果你要实现三方登录获取相关数据 那你就在相应位置 copy如下代码即可:

import

import

import

//显示分享框
[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
//获取相关信息
[[UMSocialManager defaultManager] getUserInfoWithPlatform:platformType currentViewController:self completion:^(id result, NSError *error) {
UMSocialUserInfoResponse *userinfo =result;
//获取昵称、头像、性别
NSString *message = [NSString stringWithFormat:@"name: %@\n icon: %@\n gender: %@\n",userinfo.name,userinfo.iconurl,userinfo.gender];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UserInfo" message:message delegate:nil cancelButtonTitle:NSLocalizedString(@"确定", nil) otherButtonTitles:nil]; [alert show];
}];
}

2.如果是分享的话Copy如下即可
[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
//设置文本
messageObject.title = title;
//设置网页地址
UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@“标题” descr:@“描述文本” thumImage:[UIImage imageNamed:@“图片”]];
shareObject.webpageUrl = @"网址";
messageObject.shareObject = shareObject;

    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {

        if (error) {
            
           [MBProgressHUD showHUDWithTextAutoHidden:@"分享失败"];
            
        }else{
            
            NSLog(@"response data is %@",data);
        }
        
    }];

}];
  1. 如果你是想自定义的话 就先自定义一下你要展示的分享平台
    //自定展示的分享平台顺序
    [UMSocialUIManager setPreDefinePlatforms:@[@(UMSocialPlatformType_Sina),@(UMSocialPlatformType_QQ),@(UMSocialPlatformType_WechatSession)]]; [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
    // 根据获取的platformType确定所选平台进行下一步操作
    }];

你可能感兴趣的:(2016友盟分享 iOS10 更新后使用)