实现像网页上QQ客服一样点击某按钮直接调用出聊天工具,在浏览器中可以通过JS代码打开QQ并弹出聊天界面,一般作为客服QQ使用。而在移动端腾讯貌似没有公布提供类似API,但是却可以使用schema模式来启动手机QQ。
本文主要涉及以下方面
1.应用内直接跳转到qq的聊天界面
2.判断客服端是否安装微信或者qq
第一个问题,应用内跳转到qq页面
1.配置schame
首先在info.plist里面添加LSApplicationQueriesSchemes(Array类型)
然后插入weixin, wechat, mqq的string类型子项,如下图:

2.配置urltype

3.点击跳转按钮
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
// 提供uin, 你所要联系人的QQ号码
NSString *qqstr = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",model.uin];
// 跳到微信
//NSString *str =@"weixin://qr/JnXv90fE6hqVrQOU9yA0";
NSURL *url = [NSURL URLWithString:qqstr];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
附:Android和web的跳转方法http://blog.csdn.net/chaoyong918/article/details/46882285
第二个问题:判断客服端是否安装微信
// 判断手机是否安装微信
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weixin://"]]) {
NSLog(@"install--");
}else{
NSLog(@"no---");
}
判断手机端是否安装qq
// 判断手机是否安装QQ
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
NSLog(@"install--");
}else{
NSLog(@"no---");
}
网友评论