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 <UMSocialCore/UMSocialCore.h>

import <UShareUI/UShareUI.h>

import <UShareUI/UMSocialUIManager.h>

//显示分享框
[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确定所选平台进行下一步操作
    }];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我在网上看了很多关于友盟分享的文章,可是都觉得不是很清楚,所以就结合友盟的官方文档自己研究了一下。 首先,因为懒所...
    Sun_zn阅读 1,960评论 12 2
  • ¥开启¥ 【iAPP实现进入界面执行逐一显】 〖2017-08-25 15:22:14〗 《//首先开一个线程,因...
    小菜c阅读 6,497评论 0 17
  • 党参10克、白术10克、茯苓10克、山药50克、莲子肉30克、白扁豆20克、芡实10克、薏苡仁10克,
    fa8d2ce27904阅读 209评论 0 0
  • 我在过去某段感情里患得患失,时间过了那么久,我还记得当时在飞机上突然泪流不止。 为了无望的情感辗转难眠,甚至睁眼到...
    钟灵毓秀_阅读 4,474评论 114 222
  • 我从未怀疑我的虔诚 却不停地猜忌我的忏悔 在不断地犯错中 忏悔成了我心安的救赎 我总在不断地忏悔中 不断地犯错 灵...
    从心活过阅读 247评论 7 6