Search code examples
iosswiftwhatsappopenurl

Whatsapp open url code opens Boltt Health App instead of whatsapp in ios


I am facing a very funny issue. I have written code to open WhatsApp from my app (as below). I have also handled to show a toast message to the user when whatsapp is not installed in the device. This code works perfectly fine but if the device has Boltt Health App (https://itunes.apple.com/in/app/boltt-health-fitness-anytime/id1244375641?mt=8) installed and does not have Whatsapp, so instead of showing the toast message of "Please install whatsapp from App Store" it opens Boltt Health App

** Note Everything works properly if there is no Boltt App in the device

My code to open 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)
            }
        }
    }

This is a very weird issue, would appreciate any suggestions. Thanks in advance


Solution

  • I extracted the Info.plist from this app. For some reason it registers both the whatsapp URL scheme and what appears to be a facebook URL scheme:

    enter image description here

    I don't know why this app does this, and it probably shouldn't.

    I am not sure what you can do about it; URL schemes aren't registered or protected by Apple. You could try contacting the app developers and ask them why they are registering these URL schemes. Perhaps it is an error.

    I note that the app does include WhatsApp and FaceBook in its LSApplicationQueriesSchemes, so perhaps they accidentally included them in the URL types key and forgot to remove them.