集成第三方登录(qq和微信)

第三方登录接入文档由于umeng最新的6.0似乎没有很好的支持pods所以我采用了拖动的方法

1.把文件夹UMSocial拖进项目,并选中copy Items if needed

2.在other linker flag里 添加-ObjC

3.添加以下库文件

SystemConfiguration.framework

 CoreTelephony.framework

 libsqlite3.tbd

 libc++.tbd

 libz.tbd

4.在URL Types里添加URL themes

qq,  QQ41E7D25F

weixin,wxacfc1c0815cbb42c

tencent ,tencent1105711725

5.在info plist里面添加适配代码

适配iOS10/9系统

6.把ZZConstants.h 拖进项目在app delegate.m里引入头文件

import "ZZConstant.h"

7.在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 里添加以下代码    UMSocialManager *umMgr = [UMSocialManager defaultManager];    [umMgr setUmSocialAppkey:kUMSocialAppkey];        [umMgr setPlaform:UMSocialPlatformType_WechatSession appKey:kWechatAppID appSecret:kWechatAppSecret redirectURL:kThirdRedirectUrl];        [umMgr setPlaform:UMSocialPlatformType_QQ appKey:kQQAppID appSecret:nil redirectURL:kThirdRedirectUrl];     

 8.在Appdelegate里添加-(BOOL)application:(UIApplication *)app openURL:(nonnull NSURL *)url sourceApplication:(nullable NSString *)sourceApplication annotation:(nonnull id)annotation{    BOOL result = [[UMSocialManager defaultManager]handleOpenURL:url];    if (!result) {            }    return result;}

9,在需要授权的地方引入友盟头文件

10添加方法

//授权登录

-(void)authWithPlatform:(UMSocialPlatformType)platformType

{

[ [UMSocialManager defaultManager] authWithPlatform:platformType currentViewController:self completion:^(id result, NSError *error) {

if (!error)

{

//          [self getUserInfoForPlatform:platformType];

}

UMSocialAuthResponse *authresponse = result;

NSString *message = [NSString stringWithFormat:@"result: %d\n uid: %@\n accessToken: %@\n",(int)error.code,authresponse.uid,authresponse.accessToken];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login"

message:message

delegate:nil

cancelButtonTitle:NSLocalizedString(@"确定", nil)

otherButtonTitles:nil];

[alert show];

}];

}

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容