美文网首页
iOS 打开QQ特定聊天页面

iOS 打开QQ特定聊天页面

作者: 超_iOS | 来源:发表于2018-06-28 15:55 被阅读63次

需求:唤起QQ APP 和客服QQ聊天

- (void)openQQ:(NSString *)QQ
{
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
        /*方法一
//        UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
//        NSURL * url=[NSURL URLWithString:[NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",QQ]];
//
//        NSURLRequest *request = [NSURLRequest requestWithURL:url];
////        webView.delegate = self;
//        [webView loadRequest:request];
//        [self.view addSubview:webView];
        */
//方法2:
        NSString *url = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",QQ];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
        
    }
    DLog(@"qq");
}

当然要加QQ白名单先

客服QQ需开通相关业务:

想要解决也很简单打开QQ推广设置一下就可以了
1.打开http://shang.qq.com/v3/index.html 点击推广工具------> 点击立即免费开通

相关文章

网友评论

      本文标题:iOS 打开QQ特定聊天页面

      本文链接:https://www.haomeiwen.com/subject/vlogyftx.html