IOS APP中打開指定qq聊天界面

在瀏覽器中可以通過JS代碼打開QQ并彈出聊天界面,一般作為客服QQ使用。而在移動端騰訊沒有公布提供類似API,但是卻可以使用schema模式來啟動手機(jī)QQ

//qqNumber就是你要打開的QQ號碼, 也就是你的客服號碼。

NSString? *qqNumber=@"1394381531";

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",qqNumber]];

NSURLRequest *request = [NSURLRequest requestWithURL:url];

[webView loadRequest:request];

[self.view addSubview:webView];

}else{

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"nil" message:@"對不起,您還沒安裝QQ" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

return ;

}];

[alertController addAction:cancelAction];

[self presentViewController:alertController animated:YES completion:nil];

}



注意:如果你的QQ不是客服QQ會出現(xiàn)紅色的感嘆號

想要解決也很簡單打開QQ推廣設(shè)置一下就可以了

1.打開http://shang.qq.com/v3/index.html點(diǎn)擊推廣工具------> 點(diǎn)擊立即免費(fèi)開通



轉(zhuǎn)載:? http://m.itdecent.cn/p/d306a443bcc8

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容