I'd like my iOS project to handle multiple URL types and multiple bundle identifiers, so I can install 2 versions of the app on the same device.
I have 2 different bundle IDs: com.mycompany.myapp and com.mycompany.myapp-test
I'm registering 2 URL types for both bundle identifiers in the Info.plist file
I generate 2 builds with the 2 bundle identifiers and installing both apps on the same device. Then I'm trying to reach my apps using 2 urls: myapp://feed and myapp-test://feed.
However for some reason, I cannot open myapp-test and it always opens myapp when I click on both links.
There is certainly something wrong in the way I handle this so I'm wondering how I can manage multiple bundle ID with multiple URL scheme within the same Xcode project?
Thanks
A bit of investigation produced a few solutions.
Use $(PRODUCT_BUNDLE_IDENTIFIER)
for both identifier and scheme then open each app using URL like com.mycompany.myapp://
. This will always work regardless on how many targets, schemes or build settings you have.
Set user-defined variables. You need to put these variables in your info.plist
file in order to reference them. This approach is more flexible but you have to write the scheme names by hand (only once). Actually it's the way I chosen in my applications.
This is more a workaround than a proper solution but 100% works in all cases: set identifier and scheme before build each bundle.
For example if you have identifier/scheme pairs like com.mycompany.myapp/myapp
and com.mycompany.myapp-test/myapp-test
then do the following:
com.mycompany.myapp
and scheme myapp
then build app bundle myapp
com.mycompany.myapp-test
and scheme myapp-test
then build app bundle myapp-test
This way you should be able to open each bundle calling the relative scheme. Though you will need to change the URL types before each build. Personally I would never do like this.
Make sure that:
1) for app with com.mycompany.myapp
bundle ID you registered mayapp
schema, there should be no myapp-test
schema registered;
same time,
2) for app with com.mycompany.myapp-test
bundle ID you registered myapp-test
schema, there should be no myapp
schema registered.
If I've got the problem correctly, the reason of such a behavior is both your apps are registered for both schemes. When you try to open some URL (myapp-test://... or myapp://... ) iOS detects that there is more then one app registered and picks first to handle it.
It's not needed to register schemes that you intended to open - you need to register schemes you're going to handle.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With