Reputation: 123
I have a question that I wanna open other apps in my app,
(a MDM Like App),
but after iOS 9,
using CanOpenURL to check other apps need to add Schemes in LSApplicationQueriesSchemes,
I get my apps list on websrevice so I can't add them into plist,
is there any solution to use CanOpenURL to check other apps is install or not without add scheme in LSApplicationQueriesSchemes?
Upvotes: 1
Views: 3999
Reputation: 10209
You can use UIApplication.open(_:options:completionHandler:)
whithout specifying the URLS in LSApplicationQueriesSchemes
. That key is only used for canOpenURL(_:)
.
See Apple's documentation here:
... Unlike this method, the
openURL(_:)
method is not constrained by theLSApplicationQueriesSchemes
requirement. That method works if an app is available to open the URL, whether or not you have declared the scheme.
Update
So if you need canOpenURL
, you will also need those LSApplicationQueriesSchemes
entries in the .plist
, otherwise canOpenURL
will always return false
. This restriction has been implemented in iOS 9 (I think) to prevent malicious apps from sniffing around the installed phone.
Since there is no way to add entries at runtime and wildcards aren't possible, the only solution is to directly call openURL
and check if it was successful or not. If your webservice and MDM guarantees that the apps being called are installed, this could be a viable work-around.
You could also implement something like x-callback. Think of the following:
openURL
Or your MDM (the real MDM) could send a push notification to inform about newly installed apps and their URL scheme.
Nevertheless, it's all just tricks to circumvent the restrictions apple thought of...
Upvotes: 2