How to check if an iOS app is installed without canOpenURL [duplicate] - ios

This question already has answers here:
canOpenUrl - This app is not allowed to query for scheme instragram
(3 answers)
Closed 1 year ago.
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?

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

Related

Calling external application from IOS 9 webview with Nativescript

I'm trying to open external application from webview on IOS 9 and I keep getting this error.
ispmobile://param?TID=enter_your_id
-canOpenURL: failed for URL: "ispmobile://param?TID=enter_your_id" - error:
"This app is not allowed to query for scheme ispmobile"
When I looked around, apparently there is a restriction from IOS 9 and on when calling external app and the solution that I was pointed to was to implement LSApplicationQueriesSchemes in the info.plist.
info.plist
<key>LSApplicationQueriesSchemes</key>
<string>ispmobile://</string>
I have done that and i still get the "This app is not allowed to query for scheme ispmobile" error
Any suggestions on how to fix this?
thanks in advance

Getting a LaunchServices error when trying to share to apple Books on ios

I am stuck on a problem, I'm trying to share from my app to Apple Books on iOS. When I perform the share action, the ActivityViewController acts like it is preforming the operation and everything appears to go well, however the shared file never appears in Books.
In the xcode console I get a Launch Services error:
2020-02-09 14:48:25.031316+0700 AppName[1040:282769] [default] LaunchServices: open operation <NSBlockOperation: 0x103006010> failed with error: Error Domain=NSOSStatusErrorDomain Code=-54 "Query not allowed" UserInfo={NSDebugDescription=Query not allowed, _LSLine=320, _LSFunction=-[_LSLocalQueryResolver _enumerateResolvedResultsOfQuery:XPCConnection:withBlock:]}
service was canceled
I've looked around at what could be causing this and from what I can find, it seems most likely that my app does not have the correct permissions to access iBooks, but when I run UIApplication.canOpenURL for the iBooks schemes it comes back as true.
I opened up the simulator console as well where I found a bit more to this error:
Unentitled query <_LSDocumentProxyBindingQuery: 0x10253c750> issued from pid 1021. Disallowing and yielding an error.
Could not find apps for <private>: Error Domain=NSOSStatusErrorDomain Code=-54 "Query not allowed" UserInfo={NSDebugDescription=Query not allowed, _LSLine=320, _LSFunction=<private>}.
Invalid LSOpenOperation request: Error Domain=NSOSStatusErrorDomain Code=-54 "Query not allowed" UserInfo={NSDebugDescription=Query not allowed, _LSLine=320, _LSFunction=-[_LSLocalQueryResolver _enumerateResolvedResultsOfQuery:XPCConnection:withBlock:]}
LaunchServices: [Perform] not launching application - result = Error Domain=NSOSStatusErrorDomain Code=-54 "Query not allowed" UserInfo={NSDebugDescription=Query not allowed, _LSLine=320, _LSFunction=-[_LSLocalQueryResolver _enumerateResolvedResultsOfQuery:XPCConnection:withBlock:]}
But I can't seem to find why the query is unentitled, or how to set it to be allowed.
I have tried adding the ibooks URL scheme to both LSApplicationQueriesSchemes and CFBundleURLTypes but that didn't make a difference.
I also tried saving the file manually and setting the NSFileProtectionKey to none per this post showing the same console error (not completely sure I implemented this correctly however)
I also tried using another app I've created that uses the activityVC to see if that app could share to iBooks and I get the same problem and the same error.
Sharing to all other iOS apps works fine, it is just iBooks that has the problem.
Any point in the right direction would be really appreciated!

canOpenURL, problems adding site to whitelist

I am currently updating an app and using Xcode 7.3. The app utilizes iAd banner ads and Flurry interstitial ads. When the iAd banner goes to load I get the error.
-canOpenURL: failed for URL: "about:blank" - error: "This app is not allowed to query for scheme about"
The banner loads just fine, and everything works as planned.
In researching this I found the method was deprecated for privacy reasons. However, I can not even find it in any of my files. Also, I have read about adding sites to a whitelist with LSApplicaitonQueriesSchemes. I did this in my plist with the following strings in the array;
about:blank
about
blank
The error then reads;
-canOpenURL: failed for URL: "about:blank" - error: "(null)"
I can't seem to get rid of the error no matter what I do. Does anyone have any ideas of what to do? I see a lot of info for urls that go to social media apps and such, but not for the about:blank url. Thanks in advance.
You only need to whitelist about since that is the scheme being accessed.
The message -canOpenURL: failed for URL: "about:blank" - error: "(null)" means you have everything working. iOS logs that informational message when an app tries to call canOpenURL: for a whitelisted scheme but there is no app installed that supports the given scheme. It's a confusing debug message from iOS that can be safely ignored.

Login error in iOS 9 Facebook SDK

I've seen many questions on StackOverflow about this problem, but none solved my issue.
I've created a sample app containing only the FB login button, followed the Facebook iOS 9 setup documentation, inserted ATS configs in info.plist and tried to run.
Everything works on iOS Simulator (I'm running XCode 7.1) except for a warning, but i wasn't very concerned because Facebook docs days it can be ignored.
This is the warning tho
-canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
Login works fine, and returns to the MainViewController logged in.
Problem occurs when i try to run it on device (iPhone 5, iOS 9.0.2)...
View switches to safari but after loggin in and confirming permissions, Safari fails to redirect back to the app, and says the address is invalid.
What is wrong with my application? Is there something i didn't consider?
Thanks in advance.
IOS 9 URL Shchemes Update : iOS 9 introduces LSApplicationQueriesSchemes to allow apps to query if other apps are installed.
1- If a url scheme is declared and calling canOpenURL(scheme)
YES if a installed app supports that URL scheme
NO if no app supporting that url
syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null
2- If a url scheme is not declared and calling canOpenURL(scheme)
always return NO
syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null
In iOS 9, the developer must add these info.plist LSApplicationQueriesSchemes
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>

'Open this page in "null"' Modal appearing from FacebookSDK login after iOS9 and Swift 2 upgrade

I'm in the process of updating projects to Swift 2 and iOS 9. One of the projects I'm doing relies heavily on Facebooks SDK. I use it to login, get user information, ect... Prior ot the update, once you logged in the Safari would redirect you directly to the app. Now I'm getting a fun little modal displaying the following (See Fig 1 at bottom)
I assume this has some connection to the new Info.plist key we add LSApplicationQueriesSchemes with a Item0 as fbauth2 now required by iOS 9.
I also noticed I'm getting a stack trace with my app saying:
failed for URL: "fbauth2:///" - error: "(null)"
I found the reoccurence of the new key data fbauth2 interesting, and I'm assuming that there is now a way to configure what this modal will say upon redirect. Does anyone have any idea how to configure this? I'm assuming this is a common issue for all those updating their apps. Thanks!
Fig 1
Make sure that you have updated to the newest version of the Facebook SDK at http://fb.me/FacebookSDKs-iOS-20150910.zip.
You will also want to Whitelist the Facebook Servers for Network Requests.
More information on this can be found here.
Specifically look at steps #2 & #3.
From the documentation in Step #3 there were also changes to the canOpenURL method:
Why do I see console messages like 'canOpenURL: failed for URL: "fb...://' or ?
This is an Xcode warning indicating the the canOpenURL: call returned false. As long as you have configured the LSApplicationQueriesSchemes entry in your plist as described above, you can ignore this warning

Resources