美文网首页
友盟分享

友盟分享

作者: huicuihui | 来源:发表于2018-01-26 17:56 被阅读213次

友盟分享
1、引入头文件

#import <UMSocialCore/UMSocialCore.h>
#import <UShareUI/UShareUI.h>

2、遵循协议

<UMSocialPlatformProvider,UMSocialShareMenuViewDelegate>

3、开始分享
分为两种情况:一是系统自带的分享面板,二是自定义分享面板。
使用友盟系统自带的分享面板:

-(void)shareAction{
    [UMSocialUIManager setPreDefinePlatforms:@[@(UMSocialPlatformType_WechatSession),@(UMSocialPlatformType_QQ),@(UMSocialPlatformType_WechatTimeLine)]];
    [UMSocialUIManager setShareMenuViewDelegate:self];
//        [UMSocialUIUtility configWithPlatformType:UMSocialPlatformType_QQ withImageName:nil withPlatformName:nil];
    [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
        // 根据获取的platformType确定所选平台进行下一步操作
        [self shareToPlatformType:platformType];
    }];
}

自己写的:
自定义分享平台面板
可以不使用友盟自带的分享到平台到显示面板:

[UMSocialUIManager removeAllCustomPlatformWithoutFilted];

不写上面shareAction方法里面的代码,就是不使用友盟自带的样式。

然后自己去写一个view, 显示在window上:

[[UIApplication sharedApplication].keyWindow addSubview:shareView];

点击每个按钮分享到不同的平台上面。
例如分享到朋友圈

[self shareToPlatformType:UMSocialPlatformType_WechatTimeLine];

4、

//分享到指定平台
- (void)shareToPlatformType:(UMSocialPlatformType)platformType {
    
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    

    //创建分享的网页
/**
 * @param title 标题
 * @param descr 描述
 * @param thumImage 缩略图(UIImage或者NSData类型,或者image_url)
 *
 */
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"分享到标题" descr:@"分享的描述" thumImage:[UIImage imageNamed:@"redPacketTip"]];
    shareObject.webpageUrl = @"https://www.baidu.com/";
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;

    //判断是否安装所分享到的平台, 没安装则不分享,给出提示。
    if (![self isInstall:platformType]) {
        return ;
    }

    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:nil completion:^(id data, NSError *error) {
        ;
        
        //分享失败
        if (error) {
            
        }else{
            if (platformType == UMSocialPlatformType_WechatTimeLine) {
                //分享到朋友圈成功
            } else {
                //分享到其他平台成功
            }
        }
    }];
}

判断是否安装分享平台

#pragma mark 判断是否安装分享平台
- (BOOL)isInstall:(UMSocialPlatformType)platformType {
    if (![[UMSocialManager defaultManager] isInstall:platformType]) {
        if (platformType == UMSocialPlatformType_QQ) {
            //qq
            NSLog(@"未安装QQ");
        } else {
            //weixin
        }
        return NO;
    }
    return YES;
}

相关文章

  • android-友盟如何在不同平台上分享不同数据

    友盟如何在不同平台上分享不同数据 首先我们先看下友盟的默认分享友盟默认提供了默认的分享,displaylist是不...

  • 应用资料获取-友盟密钥获取方法

    本文讲述友盟密钥应该如何获取 1.前往友盟官网,选到友盟分享模块,可以直接点击前往:点击前往友盟分享 2.点击登录...

  • Android-->友盟分享/登录快速集成库

    友盟分享/登录快速集成库 友盟分享快速集成库 本库基于友盟6.4.4的分享模块版本开发. 暂时只集成了, QQ和微...

  • iOS10之友盟分享6.8.0

    之前适配iOS9 是友盟分享5.0.1版本,请移步:友盟分享5.0.1 更新使用的友盟分享6.0.3版本至目前最新...

  • 友盟分享总结 coder_hong

    友盟分享 友盟官网集成文档 首先注册友盟账号 SDK下载Snip20160616_2.png 友盟个人中心中创建一...

  • Could not find a storyboard name

    今天集成了友盟分享,但是分享面板一直出不来,然后查看了友盟的常见问题文档 根据友盟的文档,把Main.storyb...

  • iOS9友盟分享出现常见错误

    iOS9下友盟分享 1.友盟分享出现以下错误: 原因:没适配iOS9系统 解决方法:查看友盟官方文档,在info....

  • 友盟分享

    #在做友盟分享时,分享到微信聊天,发现分享到个人成功,但是分享到微信群聊不成功; 原因是分享没有标题UMShare...

  • 友盟分享

    第一步: 在友盟官网(https://www.umeng.com)申请appKey; 申请appKey步骤 : 官...

  • 友盟分享

    导入库 UMengSocialCOM 在app启动时进行初始化 调用分享功能 自定义页面分享教程 iOS 友盟登录和分享

网友评论

      本文标题:友盟分享

      本文链接:https://www.haomeiwen.com/subject/qcewaxtx.html