SHARESDK [iOS FAQ] about using QQ to do third-party login issues!

Source: Internet
Author: User

Note:QQ itself does not have authorization function, so want to use QQ to do third-party login must through the QQ space to achieve!

The first step: integration of the SHARESDK (the same steps as integration sharing, if it has been integrated without re-integration), it is important to note that, because it is through the QQ space to achieve authorization login, So when you download the SHARESDK package, do not forget to check the QQ space, or will be reported not yet imported platform (6) error.

The second step: Open the Project *APPDELEGATE.M (* on behalf of your project name)? file, import qqsdk header file:
            #import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
CheckWhether you have joined the Handleopenurl processing method, and if not, add the following code:
- (BOOL)Application: (UIApplication*)Application Handleopenurl: (Nsurl*)Url
{
return [SHARESDK Handleopenurl:Url
Wxdelegate:Self
}

-(BOOL)Application: (UIApplication*)Application
OpenURL: (Nsurl*)Url
Sourceapplication: (NSString*)Sourceapplication
Annotation: (ID)Annotation
{
return[SHARESDK Handleopenurl: Url
Sourceapplication:Sourceapplication
Annotation: Annotation
Wxdelegate: Self
}
Step Three:Join the QQ space initialization method
inside the *APPDELEGATE.M.
- (BOOL)application: (uiapplication *)Application Didfinishlaunchingwithoptions: (nsdictionary *)launchoptions{} method
Initialize our SDK
[sharesdk registerapp:@ "iosv1101"];
Add a QQ space app
[SHARESDK Connectqzonewithappkey:@ "100371282"
Appsecret:@ "AED9B0303E3ED1E27BAE87C33761161D"
Qqapiinterfacecls:[Qqapiinterface class]
Tencentoauthcls:[Tencentoauth class;

Note:here need to fill in the Appkey is your QQ interconnection registration application Appid,appsecret is appkey!

Fourth Step:Configure the URL of the QQ space schemes

Open *-info.plist (* on behalf of your project name). Locate the URL types configuration item (if not added), expand the URL Types–url schemes, add a new scheme for QQ space under URL schemes (if not added, it will result in the return of the application). Its fill in the format: Tencent+appid (you apply in the QQ space AppID), such as: tencent100371282.

Fifth Step:authorize login and get user information

in your Click event method, add the authorization to get the user information interface:

[SHARESDK Getuserinfowithtype:Sharetypeqqspace
Authoptions:Nil
Result:^(BOOLresult, id<issplatformuser> UserInfo, id<icmerrorinfo> error){

if(Result)
{                  
//Print output user uid:
NSLog (@ "UID =%@", [UserInfo uid]);
Print output user nickname:
NSLog (@ "name =%@", [UserInfo nickname]);
Print out user picture address:
NSLog (@ "icon =%@", [UserInfo profileimage]);

}else{

NSLog (@ "Authorization failed!error code = =%d, error code = =%@", [Error ErrorCode], [error errordescription]);

}];
Note: Sharetypeqqspace here must be write qqspace can't write QQ otherwise will be reported does not support the authorization function error.
This is only done in the result output operation if you want to do the storage data or other display can be operated here!

SHARESDK [iOS FAQ] about using QQ to do third-party login issues!

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.