配置白名单
首先在info.plist里面添加LSApplicationQueriesSchemes(Array类型)
然后插入weixin, wechat, mqq的string类型子项,如下图:
代码
// 判断手机是否安装QQ
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"mqq://"]]) {
NSLog(@"install--");
}else{
NSLog(@"no---");
}
//判断手机是否安装微信
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weixin://"]]) {
NSLog(@"install--");
}else{
NSLog(@"no---");
}
跳转QQ应用
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];
NSURL *url = [NSURL URLWithString:qqstr];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
网友评论