小功能~调用QQ进行客服对话功能

网页上使用

web:

<a href="tencent://message/?uin=47460052**" target="_blank">click here</a>
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=592333**&site=qq&menu=yes">click here</a>

原生app中使用

Android:

String url="mqqwpa://im/chat?chat_type=wpa&uin=501863587";  

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));  

iOS:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSURL *url = [NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=501863587&version=1&src_type=web"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
webView.delegate = self;
[webView loadRequest:request];
[self.view addSubview:webView];

混合app

hbuilder中h5+(安卓已测试):

if (plus.os.name == "Android") {
var url = "mqqwpa://im/chat?chat_type=wpa&uin=501863**";
var Intent = plus.android.importClass("android.content.Intent");
var Uri = plus.android.importClass("android.net.Uri");
var main = plus.android.runtimeMainActivity();
var uri = Uri.parse(url);
var intent = new Intent(Intent.ACTION_VIEW, uri);
main.startActivity(intent);
}
if (plus.os.name == "iOS") {
plus.runtime.launchApplication({
action: "mqq://im/chat?chat_type=wpa&uin=634381**&version=1&src_type=web"
}, function(e) {
plus.nativeUI.confirm("检查到您未安装qq,请先到appstore搜索下载?", function(i) {
if (i.index == 0) {
iosAppstore("itunes.apple.com/cn/app/mqq/");
}
});
});
}
参考地址:
(25条消息) Android、IOS直接打开QQ或微信对应好友的聊天窗口_程序员之路-CSDN博客_android打开微信聊天窗口
http://www.weikejianghu.com/web_design/hbuilder/20175/79574.html
原文地址:https://www.cnblogs.com/lywork/p/15771727.html