友盟有个 枚举 UMSocialPlatformType
自定义的平台类型使用,用户自定义平台的预留值,如下:
截屏2020-12-1411.02.22.png上代码:
1、友盟初始化
-(void) setUM{
[[UMSocialManager defaultManager] openLog:YES];
[[UMSocialManager defaultManager] setUmSocialAppkey:UMKey];
// 新浪
[[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:WBAppid appSecret:WBAppSecret redirectURL:@"http://sns.whalecloud.com/sina2/callback"];
//QQ
[[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:QQAppid appSecret:nil redirectURL:@"http://mobile.umeng.com/social"];
//微信
[[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatTimeLine appKey:WxAppid appSecret:WxAppSecret redirectURL:@"http://mobile.umeng.com/social"];
[UMSocialUIManager addCustomPlatformWithoutFilted:UMSocialPlatformType_UserDefine_Begin+1
withPlatformIcon:[UIImage imageNamed:@"复制链接"]
withPlatformName:@"复制链接"];
[UMSocialUIManager addCustomPlatformWithoutFilted:UMSocialPlatformType_UserDefine_Begin+2
withPlatformIcon:[UIImage imageNamed:@"分享版面更多"]
withPlatformName:@"更多"];
//自定义分享选项
// UMSocialSnsPlatform *snsPlatform = [[UMSocialSnsPlatform alloc] initWithPlatformName:@"CustomPlatform"];
}
2、然后在分享事件中添加上自定义的平台 并自定义触发事件
#pragma mark - 友盟分享============================友盟分享
- (void) share{
[UMSocialUIManager setPreDefinePlatforms:
@[@(UMSocialPlatformType_Sina),
@(UMSocialPlatformType_WechatSession),
@(UMSocialPlatformType_WechatTimeLine),
@(UMSocialPlatformType_QQ),
@(UMSocialPlatformType_Qzone),
@(UMSocialPlatformType_UserDefine_Begin + 1),
@(UMSocialPlatformType_UserDefine_Begin + 2)
]];
// 配置 显示在最下面
[UMSocialShareUIConfig shareInstance].sharePageGroupViewConfig.sharePageGroupViewPostionType = UMSocialSharePageGroupViewPositionType_Bottom;
// 设置圆角
[UMSocialShareUIConfig shareInstance].sharePageScrollViewConfig.shareScrollViewPageItemStyleType = UMSocialPlatformItemViewBackgroudType_None;
[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
if (platformType == UMSocialPlatformType_UserDefine_Begin + 1) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"";
[BMWFactory showSuccess:@"链接复制成功"];
}else if (platformType == UMSocialPlatformType_UserDefine_Begin + 2){
NSLog(@"====================点击更多分享");
}else{
[self shareWithOption:platformType];
}
}];
}
网友评论