• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MobClub/ShareSDK-for-iOS: 快捷好用的社会化分享组件|Convenient SDK for SNS Share ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

MobClub/ShareSDK-for-iOS

开源软件地址:

https://github.com/MobClub/ShareSDK-for-iOS

开源编程语言:

Objective-C 97.8%

开源软件介绍:

ShareSDK For iOS

文档语言 : 中文 | English

概述

ShareSDK是一个完全免费的社会化分享组件,为移动端的iOS/Android App提供社会化功能。本组件是iOS组件,提供简单轻巧的接口,能快速实现第三方登录、获取用户信息、社会化平台分享,获取好友等功能。本组件支持国内外超过四十个主流社交平台。 集成本组件将大大缩短开发者的开发时间。同时还提供的专业的后台统计等丰富的扩展功能,助力App的推广运营。


当前版本更新(4.4.6)

更新说明:

1.修复google+新用户授权异常问题

当前版本更新(4.4.5)

更新说明:

1.修复messenger,whatsapp分享bug

当前版本更新(4.4.4)

更新说明:

1.修复Facebook首次分享不成功的bug

当前版本更新(4.4.3)

更新说明: 1.修复facebook,钉钉,evernote,Youtube,Telegram,LinkedIn,VK平台分享异常问题 2.修复5G网络报错问题 3.snapchat,抖音,kakao,微信,qq,facebook,钉钉,企业微信等第三方SDK更新

当前版本更新(4.4.2)

更新说明: 1.Line文字分享改为新的接口 2.Tumblr新增分享链接、音频、视频 3.Reddit新增分享图片

当前版本更新(4.4.1)

更新说明: 1.钉钉SDK更新,新增支持APP授权 2.Tik TokSDK更新,新增支持授权功能 3.新增支持分享图片、链接到抖音IM 4.微信授权新增state校验(以时间戳的形式设置state),防止被第三方伪造信息 5.口令分享功能问题修复

当前版本更新(4.4.0)

更新说明:

  1. 修复多个海外平台已知问题
  2. 升级微信、QQ、新浪微博等平台分享功能

当前版本更新(4.3.17)

更新说明:

  1. Facebook SDK升级为最新版本9.0
  2. Facebook Messenger分享添加SDK分享,依赖于Facebook SDK
  3. 修复部分bug

当前版本更新(4.3.16)

更新说明:

  1. Facebook SDK升级为最新版本8.2
  2. 默认关闭视频分享功能,给视频分享功能新增开关控制
  3. 修复部分bug

更多版本更新说明

当前版本更新(4.3.15)

更新说明:

  1. Facebook、Twitter、LinkedIn等平台新增系统分享接口
  2. 授权页面新增页面加载进度条
  3. 修复已知bug

更多版本更新说明

当前版本更新(4.3.11)

更新说明:

  1. 新增TikTok平台
  2. 对其他平台优化

更多版本更新说明


一、获取AppKey

如何在我们的官网注册应用得到appkey,请点击 链接 看里面的操作步骤。

二、快速集成

下面是使用Cocoapods集成方式,另一种通过官方下载相关Framework直接集成 下载地址。 ShareSDK支持使用Cocoapods集成,请按需在Podfile文件中添加以下语句:


# ============================== START ShareSDK ==============================
# 主模块(必须)
pod 'mob_sharesdk'
 
 
# UI模块(非必须,需要用到ShareSDK提供的分享菜单栏和分享编辑页面需要以下1行)
pod 'mob_sharesdk/ShareSDKUI'
 
 
# 平台SDK模块(对照一下平台,需要的加上。如果只需要QQ、微信、新浪微博,只需要以下3行)
pod 'mob_sharesdk/ShareSDKPlatforms/QQ'
pod 'mob_sharesdk/ShareSDKPlatforms/SinaWeibo'
#(微信sdk不带支付的命令)
pod 'mob_sharesdk/ShareSDKPlatforms/WeChat'   
#(微信sdk带支付的命令,和上面不带支付的不能共存,只能选择一个
# pod 'mob_sharesdk/ShareSDKPlatforms/WeChatFull')
 
# 平台SDK模块其他平台,按需添加
pod 'mob_sharesdk/ShareSDKPlatforms/RenRen'
pod 'mob_sharesdk/ShareSDKPlatforms/AliPaySocial'
pod 'mob_sharesdk/ShareSDKPlatforms/Kakao'
pod 'mob_sharesdk/ShareSDKPlatforms/Yixin'
pod 'mob_sharesdk/ShareSDKPlatforms/Facebook'
pod 'mob_sharesdk/ShareSDKPlatforms/Messenger'
pod 'mob_sharesdk/ShareSDKPlatforms/Copy'
pod 'mob_sharesdk/ShareSDKPlatforms/Evernote'
pod 'mob_sharesdk/ShareSDKPlatforms/GooglePlus'
pod 'mob_sharesdk/ShareSDKPlatforms/Instagram'
pod 'mob_sharesdk/ShareSDKPlatforms/Instapaper'
pod 'mob_sharesdk/ShareSDKPlatforms/Line'
pod 'mob_sharesdk/ShareSDKPlatforms/Mail'
pod 'mob_sharesdk/ShareSDKPlatforms/SMS'
pod 'mob_sharesdk/ShareSDKPlatforms/WhatsApp'
pod 'mob_sharesdk/ShareSDKPlatforms/MeiPai'
pod 'mob_sharesdk/ShareSDKPlatforms/DingTalk'
pod 'mob_sharesdk/ShareSDKPlatforms/YouTube'
pod 'mob_sharesdk/ShareSDKPlatforms/Twitter'
pod 'mob_sharesdk/ShareSDKPlatforms/Dropbox'
pod 'mob_sharesdk/ShareSDKPlatforms/DingTalk'
pod 'mob_sharesdk/ShareSDKPlatforms/CMCC'
pod 'mob_sharesdk/ShareSDKPlatforms/Telegram'
pod 'mob_sharesdk/ShareSDKPlatforms/Reddit'
pod 'mob_sharesdk/ShareSDKPlatforms/DouBan'
pod 'mob_sharesdk/ShareSDKPlatforms/Flickr'
pod 'mob_sharesdk/ShareSDKPlatforms/KaiXin'
pod 'mob_sharesdk/ShareSDKPlatforms/LinkedIn'
pod 'mob_sharesdk/ShareSDKPlatforms/MingDao'
pod 'mob_sharesdk/ShareSDKPlatforms/Pinterest'
pod 'mob_sharesdk/ShareSDKPlatforms/Pocket'
pod 'mob_sharesdk/ShareSDKPlatforms/Print'
pod 'mob_sharesdk/ShareSDKPlatforms/TencentWeibo'
pod 'mob_sharesdk/ShareSDKPlatforms/Tumblr'
pod 'mob_sharesdk/ShareSDKPlatforms/VKontakte'
pod 'mob_sharesdk/ShareSDKPlatforms/YouDaoNote'
pod 'mob_sharesdk/ShareSDKPlatforms/ESurfing'
pod 'mob_sharesdk/ShareSDKPlatforms/FacebookAccount'
pod 'mob_sharesdk/ShareSDKPlatforms/Douyin'
pod 'mob_sharesdk/ShareSDKPlatforms/TikTok'
 
# 使用配置文件分享模块(非必需)
pod 'mob_sharesdk/ShareSDKConfigFile'
 
 
# 扩展模块(在调用可以弹出我们UI分享方法的时候是必需的)
pod 'mob_sharesdk/ShareSDKExtension'

# ============================== END ShareSDK ==============================



三、在使用pod集成过程中以下为可能出现的问题及解决方案

如果搜索不到我们的这个mob_sharesdk时:
1、请先进行:pod setup
2、再清空一下搜索索引,让pod重建索引
rm ~/Library/Caches/CocoaPods/search_index.json
注意:之前的命令写法之后会慢慢废弃,建议都使用这个新的命令写法

CocoaPods的介绍和使用,可以参考:网页链接
如果安装过程中遇到问题,可以参考:网页链接
如果pod更新比较慢的话,可以在后面加源,需要集成的命令写法 点击此处

四、项目中配置及如何使用ShareSDK

第一步:设置ShareSDK的Appkey并初始化对应的第三方社交平台

在项目工程的Info.plist 中如图增加 MOBAppkey 和 MOBAppSecret 两个字段
在 MOBAppkey中 设置ShareSDK的appKey,如果尚未在ShareSDK官网注册过App,请移步到登录后台进行应用注册 也可以点击链接看里面的操作步骤。

友情提示:如果您同时多个MOBSDK产品 在info.plist中的设置一次就可以了。

打开*AppDelegate.m(*代表你的工程名字)导入头文件

#import <ShareSDK/ShareSDK.h>

在- (BOOL)application: didFinishLaunchingWithOptions:方法中调用registerApp方法来初始化SDK并且初始化第三方平台(各社交平台申请AppKey的网址及申请流程汇总)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [ShareSDK registPlatforms:^(SSDKRegister *platformsRegister) {
        //QQ
        [platformsRegister setupQQWithAppId:@"100371282" appkey:@"aed9b0303e3ed1e27bae87c33761161d"];
        
        //微信
        [platformsRegister setupWeChatWithAppId:@"wx617c77c82218ea2c" appSecret:@"c7253e5289986cf4c4c74d1ccc185fb1"];
        
        //新浪
        [platformsRegister setupSinaWeiboWithAppkey:@"568898243" appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3" redirectUrl:@"http://www.sharesdk.cn"];
        
        //Facebook
        [platformsRegister setupFacebookWithAppkey:@"1412473428822331" appSecret:@"a42f4f3f867dc947b9ed6020c2e93558" displayName:@"shareSDK"];
        
        //Twitter
        [platformsRegister setupTwitterWithKey:@"viOnkeLpHBKs6KXV7MPpeGyzE" secret:@"NJEglQUy2rqZ9Io9FcAU9p17omFqbORknUpRrCDOK46aAbIiey" redirectUrl:@"http://mob.com"];
        //Instagram
        [platformsRegister setupInstagramWithClientId:@"ff68e3216b4f4f989121aa1c2962d058" clientSecret:@"1b2e82f110264869b3505c3fe34e31a1" redirectUrl:@"http://sharesdk.cn"];
        
        //钉钉
        [platformsRegister setupDingTalkWithAppId:@"dingoabcwtuab76wy0kyzo"];
        
        //支付宝
        [platformsRegister setupAliSocialWithAppId:@"2017062107540437"];
        
        //豆瓣
        [platformsRegister setupDouBanWithApikey:@"02e2cbe5ca06de5908a863b15e149b0b" appSecret:@"9f1e7b4f71304f2f" redirectUrl:@"http://www.sharesdk.cn"];
        
        //Dropbox
        [platformsRegister setupDropboxWithAppKey:@"us514wslpfojbxc" appSecret:@"w0nmp4os3ngo1ja" redirectUrl:@"http://localhost"];
        
        //易信
        [platformsRegister setupYiXinByAppId:@"yx0d9a9f9088ea44d78680f3274da1765f" appSecret:@"1a5bd421ae089c3" redirectUrl:@"https://open.yixin.im/resource/oauth2_callback.html"];
        //Flickr
        [platformsRegister setupFlickrWithApiKey:@"cbed81d4a1bc7417693ab7865e354717" apiSecret:@"4c490343869091f2"];
        
        //Instapaper
        [platformsRegister setupInstapaperWithConsumerKey:@"4rDJORmcOcSAZL1YpqGHRI605xUvrLbOhkJ07yO0wWrYrc61FA" consumerSecret:@"GNr1GespOQbrm8nvd7rlUsyRQsIo3boIbMguAl9gfpdL0aKZWe"];
        
        //Line
        [platformsRegister setupLineAuthType:SSDKAuthorizeTypeBoth];
        
        //YinXiang
        [platformsRegister setupEvernoteByConsumerKey:@"46131514-6903" consumerSecret:@"08d7a6f3afcc888a" sandbox:YES];
        
        //Evernote
        [platformsRegister setupEvernoteByConsumerKey:@"46131514-6903" consumerSecret:@"08d7a6f3afcc888a" sandbox:YES];
        
        //kakao
        [platformsRegister setupKaKaoWithAppkey:@"9c17eb03317e0e627ec95a400f5785fb" restApiKey:@"802e551a5048c3172fc1dedaaf40fcf1" redirectUrl:@"http://www.mob.com/oauth"];
        
        //VKontakte
        [platformsRegister setupVKontakteWithApplicationId:@"5312801" secretKey:@"ZHG2wGymmNUCRLG2r6CY" authType:SSDKAuthorizeTypeBoth];
        
        //YouTube
        [platformsRegister setupYouTubeWithClientId:@"906418427202-jinnbqal1niq4s8isbg2ofsqc5ddkcgr.apps.googleusercontent.com" clientSecret:@"" redirectUrl:@"http://localhost"];
        
        //美拍
        [platformsRegister setupMeiPaiWithAppkey:@"1089867639"];
        
        //腾讯微博
        [platformsRegister setupTencentWeiboWithAppkey:@"801307650" appSecret:@"ae36f4ee3946e1cbb98d6965b0b2ff5c" redirectUrl:@"http://www.sharesdk.cn"];
        
        //人人网
        [platformsRegister setupRenRenWithAppId:@"226427" appKey:@"fc5b8aed373c4c27a05b712acba0f8c3" secretKey:@"f29df781abdd4f49beca5a2194676ca4" authType:SSDKAuthorizeTypeBoth];
        
        //CMCC
        [platformsRegister setupCMCCByAppId:@"300011862498" appKey:@"38D9CA1CC280C5F207E2C343745D4A4B" displayUI:YES];
        
        //有道云笔记
        [platformsRegister setupYouDaoNoteWithConsumerKey:@"dcde25dca105bcc36884ed4534dab940" consumerSecret:@"d98217b4020e7f1874263795f44838fe" oauthCallback:@"http://www.sharesdk.cn/"];
        
        //明道
        [platformsRegister setupMingDaoByAppKey:@"97230F25CA5C" appSecret:@"A5DC29AF7C5A5851F28E903AE9EAC0" redirectUrl:@"http://mob.com"];
        
        //开心网
        [platformsRegister setupKaiXinByApiKey:@"358443394194887cee81ff5890870c7c" secretKey:@"da32179d859c016169f66d90b6db2a23" redirectUrl:@"http://www.sharesdk.cn/"];
        
        //Google+
        [platformsRegister setupGooglePlusByClientID:@"351114257251-isfr7cnt5gop930krntpf246d9ofv8j5.apps.googleusercontent.com" clientSecret:@"" redirectUrl:@"http://localhost"];
        
        //Pinterest
        [platformsRegister setupPinterestByClientId:@"4987008320438021391"];
        
        //Pocket
        [platformsRegister setupPocketWithConsumerKey:@"11496-de7c8c5eb25b2c9fcdc2b627" redirectUrl:@"pocketapp1234"];
        
        //LinkedIn
        [platformsRegister setupLinkedInByApiKey:@"46kic3zr7s4n" secretKey:@"RWw6WRl9YJOcdWsj" redirectUrl:@"http://baidu.com"];
        
        //Instapaper
        [platformsRegister setupInstapaperWithConsumerKey:@"4rDJORmcOcSAZL1YpqGHRI605xUvrLbOhkJ07yO0wWrYrc61FA" consumerSecret:@"GNr1GespOQbrm8nvd7rlUsyRQsIo3boIbMguAl9gfpdL0aKZWe"];
        
        //Tumblr
        [platformsRegister setupTumblrByConsumerKey:@"2QUXqO9fcgGdtGG1FcvML6ZunIQzAEL8xY6hIaxdJnDti2DYwM" consumerSecret:@"3Rt0sPFj7u2g39mEVB3IBpOzKnM3JnTtxX2bao2JKk4VV1gtNo" redirectUrl:@"http://sharesdk.cn"];
        
        //SMS
        [platformsRegister setupSMSOpenCountryList:NO];
        
        //Telegram
        [platformsRegister setupTelegramByBotToken:@"600852601:AAElp9J93JiYevLocDIEYPhEYulnMFuB_nQ" botDomain:@"http://127.0.0.1"];
        
        //Reddit
        [platformsRegister setupRedditByAppKey:@"ObzXn50T7Cg0Xw" redirectUri:@"https://www.mob.com/reddit_callback"];
        
        //ESurfing(天翼)
        [platformsRegister setupESurfingByAppKey:@"8148612606" appSecret:@"mCltrhUqwshFa86egDTs0491ibaAulKA" appName:@"shareSDK"];
    }];
    return YES;
}

第二步:添加实现代码 打开需要集成分享功能的视图源码,把如下代码复制并粘贴到你要分享的位置,例如到响应分享按钮的方法中。并且修改相应的参数即可。

1.需要在分享的试图中导入的头文件

#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>

2.调用构造分享参数接口和分享的接口

由于苹果审核政策需求,对于那些需要客户端分享的平台,例如微信,QQ,QQ空间等,我们的分享菜单的方法里已经处理,没有安装客户端是不会在分享菜单上显示的,只有安装了才会显示。

// 使用ShareSDK提供的分享菜单
    //1、创建分享参数
    NSArray* imageArray = @[[UIImage imageNamed:@"shareImg.png"]];
    //(注意:图片可以是UIImage对象,名称必须要传正确,如果要分享网络图片,可以这样传iamge参数 images:@[@"http://mob.com/Assets/images/logo.png?v=20150320"])
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    [shareParams SSDKSetupShareParamsByText:@"分享内容"
                                     images:imageArray
                                        url:[NSURL URLWithString:@"http://mob.com"]
                                      title:@"分享标题"
                                       type:SSDKContentTypeAuto];
    //2、分享(可以弹出我们的分享菜单和编辑界面)
    //大家请注意:4.1.2版本之前(不包含) 调用此方法使用SDK提供的分享菜单
    [ShareSDK showShareActionSheet:nil //要显示菜单的视图, iPad版中此参数作为弹出菜单的参照视图,只有传这个才可以弹出我们的分享菜单,可以传分享的按钮对象或者自己创建小的view 对象,iPhone可以传nil不会影响
                             items:nil
                       shareParams:shareParams
               onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
                   switch (state) {
                       case SSDKResponseStateSuccess:
                       {
                           UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                               message:nil
                                                                              delegate:nil
                                                                     cancelButtonTitle:@"确定"
                                                                     otherButtonTitles:nil];
                           [alertView show];
                           break;
                       }
                       case SSDKResponseStateFail:
                       {
                           UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"分享失败"
                                                                           message:[NSString stringWithFormat:@"%@",error]
                                                                          delegate:nil
                                                                 cancelButtonTitle:@"OK"
                                                                 otherButtonTitles:nil, nil];
                           [alert show];
                           break;
                       }
                       default:
                           break;
                   }
               }];
    
    //大家请注意:4.1.2版本开始因为UI重构了下,所以这个弹出分享菜单的接口有点改变,如果集成的是4.1.2以及以后版本,如下调用:
    [ShareSDK showShareActionSheet:nil
                       customItems:nil
                       shareParams:shareParams
                sheetConfiguration:nil
                    onStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
                        switch (state) { 
                            case SSDKResponseStateSuccess:
                            {
                                UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                    
                      

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap