Search code examples
swifturl-scheme

Check if the Health apps are installed on user's device. (Swift)


I've checked few questions on the internet and understood how to check other apps programatically. However, I'd like to check if some particular apps are installed on the user's device, take Google fit and FitBit for example. How would I check these apps on users device? I'm not able to find any URLScheme for these apps.

Thank you.


Solution

  • Add this to your Info.plist

    <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>fitbit</string>
        </array>
    

    You can create common function to check availability of any scheme

    func schemeAvailable(scheme: String) -> Bool {
            if let url = URL(string: scheme) {
                return UIApplication.shared.canOpenURL(url)
            }
            return false
    }
    

    Then, in code your can check to see if you can open FitBit

      self.schemeAvailable(scheme: "fitbit://")