此项目是基于 https://github.com/lingochamp/Diplomat 这个开源项目改造的,感谢写这个整合的大神。
QShare.h 和 QShare.m 这两个是用来管理各个第三方容器的。
在 KeyConstants.h 中定义各个平台的 key
#define sinaWBKey @"xxx"
#define sinaAppKey @"xxx"
#define sinaRedirectURI @"xxx"
#define qqAppKey @"222222"
#define wxAppKey @"xxx"
#define wxAppSecret @"xxx"
#define rongKeyDev @"xxx"
#define rongKeyRelease @"xxx"
#define buglyAppId @"xxxx"
#define WnAppId @"xxx"
#define alischeme @"xxx"
[[QShare sharedInstance] registerWithConfigurations: @{
kQShareTypeWeibo: @{
kQShareAppIdKey: sinaAppKey,
kQShareAppRedirectUrlKey: sinaRedirectURI
},
kQShareTypeWechat: @{
kQShareAppIdKey: wxAppKey,
kQShareAppSecretKey: wxAppSecret,
},
kQShareTypeQQ: @{
kQShareAppIdKey: qqAppKey
},
kQShareTypeAli:@{
kQShareAppSchemeKey: alischeme
}
}];
@protocol QRegisterProxyProtocol // 注册的代理 @protocol QAuthProxyProtocol // 认证 @protocol QShareProxyProtocol // 分享 @protocol QPayProxyProtocol // 支付
理论上所有的第三方都要编写注册代理,然后根据需要自己接入认证或分享或支付代理
WXProxy.h
FOUNDATION_EXTERN NSString * const kQShareTypeWechat;
FOUNDATION_EXTERN NSString * const kWechatSceneTypeKey;//声明这个第三方需要的一些参数
@interface WXProxy : NSObject <QRegisterProxyProtocol, QAuthProxyProtocol, QShareProxyProtocol,QPayProxyProtocol>//几个代理都加上,再重写各个方法,
@end
WXProxy.m
+ (void)load{
[[QShare sharedInstance] registerProxyObject:[[WXProxy alloc] init] withName:kQShareTypeWechat];
}//初始化,在load保证各个第三方可以创建在容器中。