IOS based on third-party QQ authorized Login

Source: Internet
Author: User

A basic step in accessing a third-party SDK based on the iOS app's third-party QQ login:

1, find the relevant open platform, QQ interconnection platform, http://connect.qq.com/;

2, after the successful registration to create their own app, fill in a bunch of basic signals to get a app_key, is your app's unique identification code;

3, download the corresponding SDK, and read the development document or demo, usually look at the development of the document is more intuitive, if you look at the demo, some of the SDK's demo simply can't bear to stare;

4, embed the corresponding function in the SDK, after the successful Test submitted third party platform audit, and so on after the audit can be formally access to the third-party SDK function;

5, complete all functions and submit appstore audit it, about a week or so.


One, QQ login authorization development:

1, follow the development document into the SDK, and then add the key to the URL schemes after the successful registration, for example: tencent1101737816, note that these documents are written clearly;

2, in the APPDELEGATE.M implementation of the following methods, note, directly copy the code, both write one, of course, don't forget to introduce the header file, which is used as a return to the app callback function.

-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (NSString *) sourceapplication annotation: (ID) annotation{    return [Tencentoauth Handleopenurl:url];}-(BOOL) Application: ( UIApplication *) Application Handleopenurl: (Nsurl *) url{    return [Tencentoauth Handleopenurl:url];}

3, register and authorize, pay attention to authorization there will be problems

<span style= "White-space:pre" ></span>nsarray *_permissions = [Nsarray arraywithobjects:kopen_permission _get_info, Kopen_permission_get_user_info, Kopen_permission_get_simple_user_info, nil];
<span style= "White-space:pre" ></span>[_tencentoauth authorize:_permissions InSafari:NO]; Licensing </span>

4, the implementation of the successful login callback function, the implementation of protocol Tencentsessiondelegate, the code is as follows:

-(void) tencentdidlogin{    _labeltitle.text = @ "Login complete";         if (_tencentoauth.accesstoken && 0! = [_tencentoauth.accesstoken length]) {        //  record login user's OpenID, Token and expiry time        _labelaccesstoken.text = _tencentoauth.accesstoken;             } else{        _labelaccesstoken.text = @ "Login unsuccessful did not get Accesstoken";    }-(void) Tencentdidnotlogin: (BOOL) cancelled{    if (cancelled) {        _labeltitle.text = @ "user Cancel login";    } else{        _labeltitle.text = @ "Login failed";    }-(void) tencentdidnotnetwork{    [email protected] "No network connection, please set up network";

5, if the code can go to login completed here, and obtained accesstoken, that means our login process is gone, the rest of the old is to obtain user-specific information, such as nicknames, cities and so on;

6, how to get a nickname, the document provides such a method

[_tencentoauth GetUserInfo];

But the return type is a bool similar, many friends are depressed, this is what situation, after looking at the code, found that if the developer calls this method, if successful will implement the following protocol tencentsessiondelegate inside the callback function:

-(void) Getuserinforesponse: (Apiresponse *) response{//   NSLog (@ "respons:%@", response.jsonresponse);         Self.name.text = [Response.jsonresponse objectforkey:@ "nickname"];}

This will be able to get the nickname we want, and so on, even if the completion of our QQ login authorization, the rest is to send backstage these login information, and keep the token after the successful authorization, see Official document description.

IOS based on third-party QQ authorized Login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.