admin管理员组文章数量:1656243
1,首页需要去腾讯开发者平台注册应用 并且审核通过 获取appid
2,pod 'TencentOpenAPI-Unofficial', '~> 3.3.0'
#import
#import
在xcode URLtype 加入tencent这个是appid identifier :com.tencent
记得加入白名单
LSApplicationQueriesSchemes
weixin
sinaweibohd
sinaweibo
sinaweibosso
weibosdk
weibosdk2.5
mqqapi
mqq
mqqOpensdkSSoLogin
mqqconnect
mqqopensdkdataline
mqqopensdkgrouptribeshare
mqqopensdkfriend
mqqopensdkapi
mqqopensdkapiV2
mqqopensdkapiV3
mqqopensdkapiV4
mqzoneopensdk
wtloginmqq
wtloginmqq2
mqqwpa
mqzone
mqzonev2
mqzoneshare
wtloginqzone
mqzonewx
mqzoneopensdkapiV2
mqzoneopensdkapi19
mqzoneopensdkapi
mqqbrowser
mttbrowser
在appdelegate 回调
@property (nonatomic,strong) TencentOAuth *oauth;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
{
//注意: 初始化授权 开发者需要在这里填入自己申请到的 AppID
_oauth = [[TencentOAuth alloc] initWithAppId:QQ_Appid andDelegate:self];
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options{
[TencentOAuth HandleOpenURL:url];
return YES;
}
然后在第三方登录界面
- (void)getAuthWithUserInfoFromQQ{
self.tencentOAuth = [[TencentOAuth alloc]initWithAppId:@"appid" andDelegate:self];
NSMutableArray *permission = [@[] mutableCopy]; permission = [NSMutableArray arrayWithObjects:@"get_user_info",@"get_simple_userinfo",nil]; [self.tencentOAuth authorize:permission inSafari:NO];
}
#pragma mark --------- qq登录状态回调 TencentSessionDelegate------
- (void)tencentDidNotNetWork{
NSLog(@"没有网络,无法登录");
}
- (void)tencentDidLogin{
if (_tencentOAuth.accessToken){
NSLog(@"%@ == %@",_tencentOAuth.accessToken,_tencentOAuth.openId);
[self.tencentOAuth getUserInfo];
}else{
NSLog(@"登录失败!没有获取到accessToken");
}
}
/** * 登录失败后的回调 */
- (void)tencentDidNotLogin:(BOOL)cancelled{
if (cancelled){
NSLog(@"用户取消登录");
}else{
NSLog(@"登录失败");
}
}
- (void)getUserInfoResponse:(APIResponse *)response
{
NSLog(@"%@",response.jsonResponse);
}
分享
QQApiTextObject *txtObj = [QQApiTextObject objectWithText:@"share text"];
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:txtObj];
dispatch_async(dispatch_get_main_queue(), ^{
// [QQApiInterface SendReqToQZone:req];
QQApiSendResultCode sent = [QQApiInterface SendReqToQZone:req];//分享到QQ空间
[self handleSendResult:sent];
qq好友
QQApiTextObject *txtObj = [QQApiTextObject objectWithText:@"share text"];
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:txtObj];
dispatch_async(dispatch_get_main_queue(), ^{
// [QQApiInterface sendReq:req];
QQApiSendResultCode sent = [QQApiInterface sendReq:req];//分享到QQ空间
[self handleSendResult:sent];
});
- (void)handleSendResult:(QQApiSendResultCode)sendResult
{
switch (sendResult)
{
case EQQAPIAPPNOTREGISTED:
{
UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"App未注册" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
[msgbox show];
break;
}
case EQQAPIMESSAGECONTENTINVALID:
case EQQAPIMESSAGECONTENTNULL:
case EQQAPIMESSAGETYPEINVALID:
{
UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"发送参数错误" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
[msgbox show];
break;
}
case EQQAPIQQNOTINSTALLED:
{
UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您的设备未安装手机QQ" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
[msgbox show];
break;
}
case EQQAPIQQNOTSUPPORTAPI:
{
UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您的设备未安装手机QQ" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
[msgbox show];
break;
}
case EQQAPISENDFAILD:
{
UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"发送失败" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
[msgbox show];
break;
}
case EQQAPIVERSIONNEEDUPDATE:
{
UIAlertView *msgbox = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"当前QQ版本太低,需要更新" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil];
[msgbox show];
break;
}
default:
{
break;
}
}
}
版权声明:本文标题:msgbox.html5.qq.com,QQ原生第三方登录 分享接入 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729732137a1211520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论