报错:This app is not allowed to query for scheme xxx
修改info.plist文件
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mqqOpensdkSSoLogin</string>
<string>mqzone</string>
<string>sinaweibo</string>
<string>alipayauth</string>
<string>alipay</string>
<string>safepay</string>
<string>mqq</string>
<string>mqqapi</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV2</string>
<string>mqqapiwallet</string>
<string>mqqwpa</string>
<string>mqqbrowser</string>
<string>wtloginmqq2</string>
<string>weixin</string>
<string>wechat</string>
</array>
AppDelegate.m文件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//微信
[WXApi registerApp:[NSString stringWithFormat:@"wx399e40c1eda152a7"]];
return YES;
}
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
//QQ分享
// [TencentOAuth HandleOpenURL:url];
[QQApiInterface handleOpenURL:url delegate:self];
//微信分享
return [WXApi handleOpenURL:url delegate:self];
}
//代理方法(QQ、微信一样)
-(void) onReq:(BaseReq *)req {
NSLog(@"\n\n\n%@",req);
}
-(void) onResp:(BaseResp *)resp {
NSLog(@"\n\n\n%@",resp);
}
ViewController.m文件
分享微信:
- (IBAction)weixinAction:(id)sender {
WXMediaMessage *message = [WXMediaMessage message];
message.title = @"title";
message.description = @"description";
[message setThumbImage:[UIImage imageNamed:@"1"]];
WXWebpageObject *webPageObject = [WXWebpageObject object];
webPageObject.webpageUrl = @"http://www.baidu.com";
message.mediaObject = webPageObject;
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
req.bText = NO;
req.message = message;
req.scene = WXSceneSession;
[WXApi sendReq:req];
}
QQ分享文本内容:
- (IBAction)qqAction:(id)sender {
TencentOAuth *one = [[TencentOAuth alloc]initWithAppId:@"1105022167" andDelegate:self];
// [one authorize:[NSArray arrayWithObjects:@"ADD_TOPIC", nil] inSafari:NO];
QQApiTextObject *txtObj = [QQApiTextObject objectWithText:@"text"];
SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:txtObj];
//将内容分享到qq
QQApiSendResultCode sent = [QQApiInterface sendReq:req];
}