在瀏覽器中能夠經過JS代碼打開QQ並彈出聊天界面,通常做爲客服QQ使用。而在移動端騰訊貌似沒有公佈提供相似API,可是卻能夠使用schema模式來啓動手機QQ。web
如下爲具體代碼:瀏覽器
Android:ui
String url="mqqwpa://im/chat?chat_type=wpa&uin=501863587"; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
iOS:url
{
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero]; NSURL *url = [NSURL URLWithString:@"mqq://im/chat?chat_type=wpa&uin=1219953422&version=1&src_type=web"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; webView.delegate = self; [webView loadRequest:request]; [self.view addSubview:webView];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"親,木有裝QQ撒~~" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"肯定", nil];
[alertView show];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
}
瀏覽器:
spa
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=592333407&site=qq&menu=yes">click here</a>