Diplomat
1.0.0
Unify the login and sharing interfaces of third-party SDKs. Currently supports WeChat , QQ , and Weibo .
PS: Except for Weibo, which supports OAuth, other third parties only support SSO and need to install the corresponding client to use it.
Install via CocoaPods.
pod 'Diplomat'
Selective installation
pod 'Diplomat/Wechat'
pod 'Diplomat/QQ'
Import the third-party SDK you need to use.
#import <Diplomat/WechatProxy.h>
#import <Diplomat/QQProxy.h>
use
// 在 application:didFinishLaunchingWithOptions: 添加
[[Diplomat sharedInstance ] registerWithConfigurations: @{ kDiplomatTypeWechat : @{ kDiplomatAppIdKey : @" wxd930ea5d5a258f4f " ,
kDiplomatAppSecretKey : @" db426a9829e4b49a0dcac7b4162da6b6 " },
kDiplomatTypeQQ : @{ kDiplomatAppIdKey : @" 222222 " }}];
// 授权登录。
[[Diplomat sharedInstance ] authWithName: thirdPartyName
completed: ^( id result, NSError *error) {
// ...
}];
// 分享。
// Create DTMessage message ...
[[Diplomat sharedInstance ] share: message
name: thirdPartyName
completed: ^( id result, NSError *error) {
// ...
}];
userInfo is used to carry additional information.
Selection of WeChat sharing scenarios:
DTMessage *message = DTMessage()
// ...
message.userInfo = @{ kWechatSceneTypeKey : @(WXSceneTimeline)}
// WXSceneTimeline: 朋友圈(默认)、WXSceneSession: 好友、WXSceneFavorite: 收藏。
Share to QZone via Safari (thanks to @hi-guy for the contribution):
DTMessage *message = DTMessage()
// ...
message.userInfo = @{ kTencentQQSceneTypeKey : @(TencentSceneZone)}
// TencentSceneQQ: 通过 QQ 客户端分享(默认,包含了分享到 QZone 选项),
// TencentSceneZone: 通过 Safari 只分享到 QZone (有 QQ 客户端时不推荐使用)。