Swift打开QQ或者TIM聊天页面

2019-10-10  本文已影响0人  Best_Kai

1、在info.plist文件新增 LSApplicationQueriesSchemes 字段配置参考http://wiki.mob.com/6803-2/白名单(TIM和qq的必须添加)

2、相关代码

    if(UIApplication.shared.canOpenURL(URL(string: "mqq://")!)){
        let str =  String(format: "mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web", qq)
        UIApplication.shared.openURL(URL(string: str)!)
    }else if (UIApplication.shared.canOpenURL(URL(string: "tim://")!)){
        let str =  String(format: "tim://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web", qq)
        UIApplication.shared.openURL(URL(string: str)!)
    }
上一篇 下一篇

猜你喜欢

热点阅读