我面临一个非常有趣的问题。我已编写代码从我的应用程序打开WhatsApp(如下所示)。我还处理过在设备中未安装whatsapp时向用户显示toast消息。这段代码工作得非常好但是如果设备安装了Boltt Health App(https://itunes.apple.com/in/app/boltt-health-fitness-anytime/id1244375641?mt=8)并且没有Whatsapp,那么它不会显示“请从App Store安装whatsapp”的Toast消息,而是打开Boltt Health App
**注意如果设备中没有Boltt App,一切正常
我的代码打开whatsapp
let urlWhats = "whatsapp://send?phone=\(mobileNo)&text=\(msg)"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
if let whatsappURL = NSURL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL as URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(whatsappURL as URL, options: [ : ], completionHandler: nil)
} else {
UIApplication.shared.openURL(whatsappURL as URL)
}
} else {
CommonMethods.showToast(messsage: "Please install whatsapp from App Store", view: view)
}
}
}
这是一个非常奇怪的问题,将不胜感激任何建议。提前致谢