微信QQ分享回话

来源:互联网 发布:网络电话机怎么安装 编辑:程序博客网 时间:2024/04/29 12:37


报错: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.

    //微信

    [WXApiregisterApp:[NSStringstringWithFormat:@"wx399e40c1eda152a7"]];

    returnYES;

}


-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {

    //QQ分享

//    [TencentOAuth HandleOpenURL:url];

    [QQApiInterfacehandleOpenURL:url delegate:self];  

    //微信分享

    return [WXApihandleOpenURL: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 = [WXMediaMessagemessage];

    message.title = @"title";

    message.description  = @"description";

    [message setThumbImage:[UIImageimageNamed:@"1"]];

    WXWebpageObject *webPageObject = [WXWebpageObjectobject];

    webPageObject.webpageUrl =@"http://www.baidu.com";

    message.mediaObject = webPageObject;

    SendMessageToWXReq *req = [[SendMessageToWXReqalloc] init];

    req.bText = NO;

    req.message = message;

    req.scene = WXSceneSession;

    [WXApi sendReq:req];

    

}



QQ分享文本内容:

- (IBAction)qqAction:(id)sender {

    

    TencentOAuth *one = [[TencentOAuthalloc]initWithAppId:@"1105022167"andDelegate:self];

//    [one authorize:[NSArray arrayWithObjects:@"ADD_TOPIC", nil] inSafari:NO];

    

    QQApiTextObject *txtObj = [QQApiTextObjectobjectWithText:@"text"];

    SendMessageToQQReq *req = [SendMessageToQQReqreqWithContent:txtObj];

   //将内容分享到qq

    QQApiSendResultCode sent = [QQApiInterfacesendReq:req];

}




0 0
原创粉丝点击