@Override public void onCreate() { super.onCreate(); SoLoader.init(this,false); Config.shareType = "react native"; UMShareAPI.get(this); } // 配置平台 { PlatformConfig.setWeixin("wx083bf496cbc48aec", "750e9075fa521c82274a9d548c399825"); PlatformConfig.setQQZone("1106207359", "3JjbG8aXMuh5w0sV"); PlatformConfig.setSinaWeibo("2733400964", "fac50980a44e3e3afd4bc968ea572887", "www.baidu.com"); }
10. 在MainActivity中初始化分享回调【直接复制源码即可】
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ShareModule.initActivity(this); }
【 iOS平台配置 】
1. 将源码中 ios 目录下的UMSocial添加到工程,直接拖进即可
2. 选择TARGET下的项目,在Build Setting下找到Other Linker Flags加入-ObjC ,注意不要写为-Objc
3. 加入U-Share SDK依赖的系统库
依次添加如下依赖:
SystemConfiguration.framework
CoreGraphics.framework
CoreTelephony.framework
ImageIO.framework
libsqlite3.tbd
libc++.tbd
libz.tbd
4. 在Info.plist文件下配置SSO白名单【直接复制即可】
<key>LSApplicationQueriesSchemes</key> <array> <!-- 微信 URL Scheme 白名单--> <string>wechat</string> <string>weixin</string> <!-- 新浪微博 URL Scheme 白名单--> <string>sinaweibohd</string> <string>sinaweibo</string> <string>sinaweibosso</string> <string>weibosdk</string> <string>weibosdk2.5</string> <!-- QQ、Qzone、TIM URL Scheme 白名单--> <string>mqqapi</string> <string>mqq</string> <string>mqqOpensdkSSoLogin</string> <string>mqqconnect</string> <string>mqqopensdkdataline</string> <string>mqqopensdkgrouptribeshare</string> <string>mqqopensdkfriend</string> <string>mqqopensdkapi</string> <string>mqqopensdkapiV2</string> <string>mqqopensdkapiV3</string> <string>mqqopensdkapiV4</string> <string>mqzoneopensdk</string> <string>wtloginmqq</string> <string>wtloginmqq2</string> <string>mqqwpa</string> <string>mqzone</string> <string>mqzonev2</string> <string>mqzoneshare</string> <string>wtloginqzone</string> <string>mqzonewx</string> <string>mqzoneopensdkapiV2</string> <string>mqzoneopensdkapi19</string> <string>mqzoneopensdkapi</string> <string>mqqbrowser</string> <string>mttbrowser</string> <string>tim</string> <string>timapi</string> <string>timopensdkfriend</string> <string>timwpa</string> <string>timgamebindinggroup</string> <string>timapiwallet</string> <string>timOpensdkSSoLogin</string> <string>wtlogintim</string> <string>timopensdkgrouptribeshare</string> <string>timopensdkapiV4</string> <string>timgamebindinggroup</string> <string>timopensdkdataline</string> <string>wtlogintimV1</string> <string>timapiV1</string> <!-- Facebook URL Scheme 白名单--> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array>
5. 配置URL Scheme
微信
微信appKey
wxdc1e388c3822c80b
QQ/Qzone/TIM
需要添加两项URL Scheme:
1、"tencent"+腾讯QQ互联应用appID
2、“QQ”+腾讯QQ互联应用appID转换成十六进制(不足8位前面补0)
如appID:100424468 1、tencent100424468
2、QQ05fc5b14
QQ05fc5b14为100424468转十六进制而来,因不足8位向前补0,然后加"QQ"前缀
新浪微博
“wb”+新浪appKey
wb3921700954
6.在AppDelegate.m中初始化U-Share及第三方平台
(1)引入头文件: #import<UMSocialCore/UMSocialCore.h>【直接复制即可】
(2)launchOptions中设置友盟Key【直接复制即可】
/* 打开调试日志 */ [[UMSocialManager defaultManager] openLog:YES]; /* 设置友盟appkey */ [[UMSocialManager defaultManager] setUmSocialAppkey:USHARE_DEMO_APPKEY]; [self configUSharePlatforms]; [self confitUShareSettings];
(3)在AppDelegate.m文件下添加如下代码,配置第三方平台【直接复制即可】
launchOptions: