Android,iOS打开手机QQ与指定用户聊天

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

以下为具体代码:

Android:

  1. String url="mqqwpa://im/chat?chat_type=wpa&uin=123456";  
  2. startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); 

       uin=临时会话的qq账号

String url="mqqwpa://im/chat?chat_type=wpa&uin=123456";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));


iOS:

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

浏览器:

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



转载:http://blog.csdn.net/qduningning/article/details/40587099

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值