微信QQ分享回话

本文介绍如何通过修改info.plist文件并配置AppDelegate.m文件,解决iOS应用在尝试使用微信、QQ等第三方分享服务时遇到的权限报错问题。通过注册应用ID和配置代理方法,实现应用在启动时正确初始化第三方分享服务,确保应用能够顺利分享内容至微信、QQ平台。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


报错: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];

}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值