iOS QQ login

QQSDK

Tell me what network the document is indeed vexing one thing, that is two resource file, to find a (TencentOpenAPI.framework), Demo is also not found.

The next realization:

Import library:

 Adding SDK dependent system libraries. Are "Security.framework", "libiconv.dylib", "SystemConfiguration.framework", "CoreGraphics.Framework", "libsqlite3.dylib", "CoreTelephony.framework", "libstdc ++. Dylib", "libz.dylib"

Add URL Types URL_Schemes = tencent + appid

We found not to go after configuring the callback method. There are about two points,

1. Add whitelist

 

<key>LSApplicationQueriesSchemes</key>
<array>
<string>mqq</string>
<string>mqqapi</string>
<string>mqqwpa</string>
<string>mqqbrowser</string>
<string>mttbrowser</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV4</string>
<string>wtloginmqq2</string>
<string>mqzone</string>
<string>mqzoneopensdk</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapiV2</string>
<string>mqqapiwallet</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkdataline</string>
<string>mqqgamebindinggroup</string>
<string>mqqopensdkgrouptribeshare</string>
<string>tencentapi.qq.reqContent</string>
<string>tencentapi.qzone.reqContent</string>
</array>

 

 

 

Set after 2 Recall

In AppDelegate.m introduced (the best set globally, but also used when logging)

 

#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([url.host isEqualToString:@"qzapp"]) {
 
[QQApiInterface handleOpenURL:url delegate:(id<QQApiInterfaceDelegate>)[QQApiNewsObject class]];
 
return [TencentOAuth HandleOpenURL:url];
 
}
 
return YES;
}

 

Log in VC achieve

The introduction of proxy method:  TencentSessionDelegate

// declare variables 
@Property (nonatomic, strong) TencentOAuth * tencentOAuth; 
// determines whether loaded QQ - ( void ) {lookQQAuth self.tencentOAuth = [[TencentOAuth the alloc] initWithAppId: @ " AppId " andDelegate: Self]; BOOL isInstallQQ = [TencentOAuth iphoneQQInstalled]; IF (isInstallQQ == NO) { [self.qqLogin setHidden: YES]; } } // log function: - ( void ) {qqLoginBtnAction NSString * AppID = TencentAppid; _tencentOAuth = [[TencentOAuth alloc] initWithAppId:appid andDelegate:self]; NSMutableArray * permission = [NSMutableArray arrayWithObjects:@[kOPEN_PERMISSION_GET_INFO, kOPEN_PERMISSION_GET_USER_INFO, kOPEN_PERMISSION_GET_SIMPLE_USER_INFO],nil]; [_tencentOAuth authorize:permission inSafari:NO]; } #pragma mark --------- qq登录状态回调 TencentSessionDelegate------ //登录成功: - (void)tencentDidLogin { if (_tencentOAuth.accessToken.length > 0) { // 获取用户信息 [_tencentOAuth getUserInfo]; [_qqInfoDict setValue:_tencentOAuth.openId forKey:@"openid"]; }the else { NSLog ( @ " sign in an unsuccessful did not get accessToken " ); } } // non-Logon failed due to network error: - ( void ) tencentDidNotLogin: (BOOL) Canceled { IF (Canceled) { NSLog ( @ " user cancels the login " ); } the else { NSLog ( @ " login failed " ); } } - ( void ) {tencentDidNotNetWork NSLog ( @ " check network " ); } // get user information - ( void) getUserInfoResponse: (APIResponse * ) Response { IF (Response && response.retCode == URLREQUEST_SUCCEED) { // string dictionary transferred user information fetch NSDictionary the userInfo * = [NSString dictionaryWithJsonString: response.message]; // start log (requesting server ) [Self qqLoginRequest]; } the else { NSLog ( @ " QQ the auth Fail, getUserInfoResponse:% D " , response.detailRetCode); } }

 

 

 

Guess you like

Origin www.cnblogs.com/xingsmile/p/10937716.html