<key>LSApplicationQueriesSchemes</key>
<array>
<string>mqq</string>
<string>wtloginmqq2</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV2</string>
<string>mqqwpa</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqzone</string>
<string>mqzone</string>
<string>mqqapi</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
主要代码:
//
// ViewController.m
// QQLogin_ShareDemo
//
// Created by Tina on 15/12/7.
// Copyright © 2015年 Tina. All rights reserved.
//
#import "ViewController.h"
#import "TencentOpenAPI/TencentOAuth.h"
@interface ViewController ()<TencentSessionDelegate>
{
TencentOAuth *_tencentOAuth;
NSArray *_permissions;
}
@property (strong, nonatomic) IBOutlet UIView *loginButton;
- (IBAction)Click:(UIButton *)sender;
- (IBAction)ShareClick:(UIButton *)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_tencentOAuth = [[TencentOAuth alloc]initWithAppId:@"1104800177" andDelegate:self];
_permissions = [[NSArray alloc]initWithObjects:kOPEN_PERMISSION_GET_USER_INFO,kOPEN_PERMISSION_ADD_SHARE,kOPEN_PERMISSION_GET_SIMPLE_USER_INFO, nil];
}
-(void)tencentDidNotNetWork
{
NSLog(@"no netWork");
}
-(void)tencentDidNotLogin:(BOOL)cancelled
{
if (cancelled)
{
// 记录登录用户的OpenID、Token以及过期时间
NSLog(@"cancel");
}
else
{
NSLog(@"fail");
}
}
-(void)getUserInfoResponse:(APIResponse *)response
{
NSLog(@"respons:%@",response.jsonResponse);
}
-(void)tencentDidLogin
{
if (_tencentOAuth.accessToken && 0 != [_tencentOAuth.accessToken length])
{
// 记录登录用户的OpenID、Token以及过期时间
NSLog(@"accessToken:%@",_tencentOAuth.accessToken);
[_tencentOAuth getUserInfo];
}
else
{
NSLog(@"fail");
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Click:(UIButton *)sender {
NSLog(@"iphoneQQSupportSSOLogin:%d",[TencentOAuth iphoneQQSupportSSOLogin]);
NSLog(@"iphoneQQInstalled:%d",[TencentOAuth iphoneQQInstalled]);
//if ([TencentOAuth iphoneQQInstalled]) {
[_tencentOAuth authorize:_permissions];
//}
}
- (IBAction)ShareClick:(UIButton *)sender {
NSLog(@"分享按钮");
}
@end