//是否安装QQ
if UIApplication.shared.canOpenURL(URL(string: "mqq://")!){
//指定号码跳转到QQ聊天界面
let qqStr = String("mqq://im/chat?chat_type=wpa&uin=" + 指定qq号码 + "&version=1&src_type=web")
let url = URL(string: qqStr!)
UIApplication.shared.openURL(url!)
}else{
//提醒没安装qq
}
//是否安装QQ
if UIApplication.shared.canOpenURL(URL(string: "mqq://")!){
let qqWebView = UIWebView(frame: CGRect.zero)
let url = "mqq://im/chat?chat_type=wpa&uin=" + 指定qq号码 + "&version=1&src_type=web"
let request = URLRequest(url: URL(string: url)!)
qqWebView.delegate = self
qqWebView.loadRequest(request)
self.view.addSubview(qqWebView)
}else{
//提醒没安装qq
}
- 最重要的是qq号码一定先开通推广功能才能进行临时对话:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mqq</string>
</array>