Whatsapp打开网址代码在ios中打开Boltt Health App而不是whatsapp

问题描述 投票:0回答:1

我面临一个非常有趣的问题。我已编写代码从我的应用程序打开WhatsApp(如下所示)。我还处理过在设备中未安装whatsapp时向用户显示toast消息。这段代码工作得非常好但是如果设备安装了Boltt Health App(https://itunes.apple.com/in/app/boltt-health-fitness-anytime/id1244375641?mt=8)并且没有Wha​​tsapp,那么它不会显示“请从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)
            }
        }
    }

这是一个非常奇怪的问题,将不胜感激任何建议。提前致谢

ios swift whatsapp openurl
1个回答
1
投票

我从这个应用程序中提取了Info.plist。由于某种原因,它注册了whatsapp URL方案和看似是facebook URL方案:

enter image description here

我不知道为什么这个应用程序这样做,它可能不应该。

我不确定你能做些什么; Apple方案未注册或保护URL方案。您可以尝试联系应用程序开发人员,并询问他们为什么要注册这些URL方案。也许这是一个错误。

我注意到该应用程序确实在其LSApplicationQueriesSchemes中包含WhatsApp和FaceBook,因此可能他们不小心将它们包含在URL类型键中并忘记删除它们。

© www.soinside.com 2019 - 2024. All rights reserved.