Android,iOS,浏览器打开手机QQ与指定用户聊天界面

在浏览器中可以通过JS代码打开QQ并弹出聊天界面,一般作为客服QQ使用。而在移动端腾讯貌似没有公布提供类似API,但是却可以使用schema模式来启动手机QQ。

以下为具体代码:

浏览器(包括手机浏览器):

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

如果提示需要加对方为好友才可以进行对话。这样子说明对方没有开通临时会话的服务,不能进行QQ的临时会话。

需要开启临时会话的功能,进入QQ商家官网:http://shang.qq.com/index.php   QQ商家沟通组件——设置中进行开通 参考地址

Android:

String url="mqqwpa://im/chat?chat_type=wpa&uin=572839485";
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=572839485&version=1&src_type=web"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
webView.delegate = self;
[webView loadRequest:request];
[self.view addSubview:webView];

  

原文地址:https://www.cnblogs.com/zyw-205520/p/4750911.html