集成第三方登录(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];

}];

}

你可能感兴趣的:(集成第三方登录(qq和微信))