前提: 如果你想要你的QQ在app项目中成为客服QQ, 首先需要你去腾讯官方将你的QQ注册为客服QQ才可以实现下面的步骤
这个其实有点坑, 但是有代码是然并卵, 需要在info.plist文件中进行配置才可以使用: 上swift代码和info.plist中需要配置授权代码
// 按钮事件中唤醒QQ聊天界面
func didClickButton() {
let webView = UIWebView(frame: self.view.bounds)
let url1 = URL(string: "mqq://im/chat?chat_type=wpa&uin=2100886100&version=1&src_type=web")
let request = NSURLRequest(url: url1!)
webView.delegate = self
webView.loadRequest(request as URLRequest)
view.addSubview(webView)
}
- 重点当然是info.plist文件中需要配置的代码了, 将这段代码复制到info.plist当中即可
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>alipayshare</string>
<string>alipay</string>
<string>mqqapi</string>
<string>wechat</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqq</string>
<string>mqzoneopensdkapiV2</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdk</string>
<string>mqzone</string>
<string>weixin</string>
<string>mqqopensdkapiV2</string>
</array>