iOS-友盟SDK6.4,自定义分享

来源:互联网 发布:软件锁许可管理器 cad 编辑:程序博客网 时间:2024/06/05 17:05

1、

在 SDK 路径UMSocalSDK -- UMSocialCore.framework -- Headers -- UMSocialPlatformConfig.h 

文件中定义你需要的平台类型

//用户自定义的平台UMSocialPlatformType_UserDefine_Begin = 1000,UMSocialPlatformType_GZB              = 1001,//GZBUMSocialPlatformType_UserDefine_End = 2000,

2、创建QXCustomSharePlatform类

// QXCustomSharePlatform.h
#import <UMSocialCore/UMSocialCore.h>
@interface QXCustomSharePlatform : UMSocialHandler <UMSocialPlatformProvider>

@end

3、

在QXCustomSharePlatform.m中,实现友盟文档要求一定要实现的方法:

+(void)load{

[superload];

}

+(NSArray*) socialPlatformTypes

{

return @[@(UMSocialPlatformType_UserDefine_Begin+1)];

}

+ (UMSocialTemplateHandler *)defaultManager

{

static UMSocialTemplateHandler *instance = nil;

staticdispatch_once_t onceToken;

dispatch_once(&onceToken, ^{

if (!instance) {

instance = [[self alloc] init];

}

});

return instance;

}

// 点击自定义平台的图标之后,会走这个方法,我这里是发送通知,告诉实现功能的页面要分享什么

- (void)umSocial_ShareWithObject:(UMSocialMessageObject *)object withCompletionHandler:(UMSocialRequestCompletionHandler)completionHandler
{
    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    [notificationCenter postNotificationName:@"ShareToLocalNotification" object:nil userInfo:nil];
}


4、

在友盟分享中添加自己自定义的平台

 [UMSocialUIManager addCustomPlatformWithoutFilted:UMSocialPlatformType_GZB withPlatformIcon:@“自己平台的图片” withPlatformName:@“自己平台的名字”];

[UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {

...

}];





原创粉丝点击