0

As described here to verify if an app is installed "some.bundle.id://" scheme and canOpenURL technique can be used.

However, I've discovered in SwiftUI 5 and iOS 14.1 that it doesn't always work, e.g.

// Works    
UIApplication.shared.canOpenURL(URL(string: "com.garmin.connect.mobile://")!)  

// Doesn't work
UIApplication.shared.canOpenURL(URL(string: "com.fitbit.FitbitMobile://")!)    

I've found the error below in Mac's Console App log connected to iPhone. Looks like Fitbit app is blocking the queries:

default 12:03:34.339735-0700    2fahub  -canOpenURL: failed for URL: "FitbitMobile://app" - error: "This app is not allowed to query for scheme fitbitmobile"

While in my Xcode's debug window I can see this:

2021-05-30 12:46:16.416998-0700 2fahub[588:100068] -canOpenURL: failed for URL: "com.fitbit.FitbitMobile://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

In my app query permissions are set correctly

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>com.garmin.connect.mobile</string>
    <string>com.fitbit.FitbitMobile</string>
</array>

What else can be used to make sure that it always works? Is there anything similar to Android's PackageManager API in iOS?

Update #1:

Actually the answer provided by Fitbit forum was correct. The scheme for Fitbit must be "fitbit://" and it's absolutely not clear why, given that bundle ID for this app is com.fitbit.FitbitMobile. 'fitbit' is not the app name, neither it's the whole bundle ID. In Garmin case I must use the whole bundle ID to make it working. Would be good to know what the rules really are here. What should I do if need to add more apps to verify?

Oleg Gryb
  • 5,122
  • 1
  • 28
  • 40

1 Answers1

3

Seems the Fitbit's URL Scheme is not com.fitbit.FitbitMobile://(this is it's bundle id)\

Try with fitbit://

These two posts seem to have it working
Answer from 2016 - community.fitbit.com
Answer from 2020 - community.fitbit.com

Gicck
  • 521
  • 3
  • 3
  • Thank you. "fitbit://" worked but it's absolutely not clear why given that fitbit is not the app name, nor the whole bundle ID. Please vote to reopen, because other refs were absolutely pointless – Oleg Gryb Jun 01 '21 at 07:24
  • **fitbit** is the URL Scheme putting the bundle ID or the app name on LSApplicationQueriesSchemes simply won't work, [LSApplicationQueriesSchemes - Summary](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#:~:text=specifies%20the%20url%20schemes%20the%20app%20is%20able%20to%20test%20using%20the%20canopenurl). There is a good posibility that garmin set it's URL Scheme and bundle ID as **com.garmin.connect.mobile** – Gicck Jun 02 '21 at 03:18