How to handle universal links only from subdomain in iOS app? - ios

I have got a problem. There are two instances of app with different bundleID for dev and for prod. This apps can handle universal links. Problem is that where one apps trying to open link in safari, second (if they are both installed on the phone) app handles this link and open it by itself. So when one app wants to open safari another handles it and open itself. For example:
www.dev-domain.maindomain.com/id980 - dev link
www.prod-domain.maindomain.com/id980 - prod link
in project capabilities it's looks like applinks:*.maindomain.com
I was trying to applinks:dev-domain.maindomain.com or prod-domain.maindomain.com for different bundles but in this case handling universal links didn't works at all. AASA file located on www.maindomain.com/apple-app-site-association
How can I handle this situation, so prod app will handle only prod domain links and dev only dev?

Related

Firebase dynamic link not opening correct app when multiple flavors are installed on iOS

We developed a flutter app for Android and iOS, with different flavors: dev, test and prod, so we have 6 apps in total. To on-board the user, we send a firebase dynamic link via Email (with a deep link inside it) to navigate the user to a specific screen when it is tapped.
The expected behavior is that when the user taps on a dynamic link of - say - the dev app, it opens a screen in the dev app. Similar for the other flavors.
Now this works just fine on Android.
On iOS it works fine if only one app is installed, but if for example the dev and the test apps are installed, then tapping on the dynamic links always opens the test app. This is also true when dev, test and prod are installed: test is opened.
This is a development issue and not relevant for production as the user will never have the test or dev app installed, but it is annoying us as we have to uninstall and reinstall flavors all the time.
Our dynamic links have the following format (values in '<>' are placeholders):
Dev: https://<app_id>.page.link/?link=http://dev.<mydomain>.com/reset?token=token1&apn=<mypackage>.dev&isi=<isiNumber1>&ibi=<mypackage>.dev
Test: https://<app_id>.page.link/?link=http://test.<mydomain>.com/reset?token=token2&apn=<mypackage>.test&isi=<isiNumber2>&ibi=<mypackage>.test
Prod: https://<app_id>.page.link/?link=http://<mydomain>.com/reset?token=token3&apn=<mypackage>&isi=<isiNumber3>&ibi=<mypackage>
The behavior is the same for all iOS versions I could get my hands on on real devices, i.e. iOS 11, 12 and 13.
We're using Flutter 1.9.1-hotfix6 and firebase_dynamic_links 0.5.0+1
Any ideas what this might be caused by?
Firebase Dynamic Links do not support using the same URL prefix for multiple iOS apps/targets contained in the same Firebase project.
You can workaround this in multiple ways though:
Using multiple (sub)domains (as already suggested by Janmenjaya)
Use a custom domain
Using multiple Firebase projects (as already suggested by Aleksandr)
On Android it works out of the box, because you are in charge of matching paths with particular apps within the Manifest file. On iOS it doesn't work, because Firebase is in charge of such matches within the hosted apple-app-site-association file.
For further information, I've written an extensive answer here.
Do not use one project in the firebase console, it is better to split and use different url in <key>com.apple.developer.associated-domains</key>
In Firebase under dynamic link, we can create multiple url domain. And these url domain we need to add in the associated domain of different target.
Steps
Let’s assume I have two target test and production.
I created two domain link like “test.page.link” and production.page.link
In test target in Xcode under Signing & Capabilities -> Associated Domain, use the “test.page.link”
And for production target set the production.page.link

Universal links for iOS apps - how it works?

I am new to adding universal links to iOS applications. I have read some materials but still have a few questions below. Any pointer will be greatly appreciated!
When exactly Apple will crawl my domain and inspect the [domain]/apple-app-site-association content? I have a new domain, and I'm wondering how Apple's crawler can discover it?
What's the recommended way to test universal links locally before publishing the first version of my app?
Is version control for universal links not possible? For example, the app 1.0 version only supports \item universal link, but app 2.0 version supports one more schema \details . If I specify both paths in apple-app-site-association, then the 1.0 app will break when user navigate to \details. (Edit: I noticed that if the app appropriately set it to be unhandled, then we can still fall back to browser.)
Thanks!
When a device downloads an app, it looks for an entitlements file to list out your associated domains. When it finds that your app has associated domains, it will check those domains for the aasa and download it onto the device. The aasa for that app will only be downloaded on install and update so changes you make will not effect all of your apps.
For testing you can host your AASA on a testing domain or on your production domain. It's up to you but you have to remember to update your entitlements file when you push it to production to ensure that you have the right domain configured. Every time you rebuild the app, it should re-download the aasa so testing shouldn't be too difficult. Always remember to paste the link in notes and not type it into Safari. Universal links only work when they are tapped, not typed in.
For your example you should make sure your new AASA is published at the exact time you publish your app. You should probably use a separate testing domain to host your AASA. You can just include both domains in your entitlements.
Branch actually has testing environment and AASA hosting built in if you'd prefer not to handle all of that on your own. They also leverage URI schemes in cases where Universal Links don't work.

Having problems opening a custom enterprise app from with another custom app

I have a couple of custom apps (masterapp and app2), both belonging to the same custom URL scheme. When I click a button on the masterapp, I want it to open app2.
I've noticed a weird pattern where by the master app only opens app2 if app2 was installed before the master app.
If I install the masterapp, then install app2 then click the button to open app2 it just doesn't do anything.
Can anyone explain this behaviour and what is going on? I've played around with URL schemes for days now but can't get this to work properly.
You can't do this.
The URI scheme need to be unique to each app. There have actually been a few instances where third-party apps attempt to hijack the private URI schemes of popular apps, and this is part of the reason Apple introduced Universal Links in iOS 9.
If you think it through logically, the behavior you are experiencing makes perfect sense: if two apps with the same URI scheme are installed, then the app you installed first is the one that will respond when that URI scheme is triggered.

Universal Links on macOS

Since iOS9, universal links work on iOS, but I am wondering if there is something like that on macOS? We have an application that is a macOS-App with a corresponding Web-App, and we would love links clicked by the user to open in the Mac-App instead of opening the browser with the target-link.
Is that anyhow possible on macOS? I just found samples for iOS, but none for macOS?!?
Supporting Universal Links on macOS requires support from both your app and your website (and macOS 10.15+).
See Apple's documentation Allowing Apps and Websites to Link to Your Content for details (the article deals with iOS, tvOS and macOS deep links), and its sub-articles Enabling Universal Links as well as Handling Universal Links.
Quick overview:
Basically, it's the same as on iOS: you need to create an apple-app-site-association file that is hosted on your server either in the root directory or in the .well-known directory (described in "Enabling Universal Links" linked above). It describes which URL paths can be passed to your app. It's important that this file is valid JSON (validate it!) and is served via HTTPS with a valid certificate and without any redirects!
You need to enable the "Associated Domains" capability in your provisioning profile. Details depend on whether Xcode manages your profiles or not. In your entitlements file (usually editable via the "Signing & Capabilities" tab of your target in Xcode) you need add the corresponding associated domain, like applinks:my.domain.example (no https:// or anything, just the raw domain name).
Then you need to implement application(_:continue:restorationHandler:) in your app delegate to handle the Universal Link.
It can be annoying to make macOS pick up the association for the first time during development. Debugging hints:
Open Console.app and filter for swcd, that's the daemon responsible for associated web credentials and Universal Links. Sometimes you see hints why it did not work (like refusing the apple-app-site-association file).
Also I had to kill the swcd daemon to make it get restarted by launchd and then pick up changes/fixes I did to the apple-app-site-association file. Both iOS and macOS should usually reload this file on "app installation"1 (haven't seen this getting specified more clearly; I guess they mean App Store installs/updates but I don't know about when this is loaded for macOS apps distributed outside the App Store).
Also, be aware that entering a Universal Link in Safari will not hand off to your app: Apple has stated in the dev forums2 that they believe if a user is already in the browser environment they want to stay there and not suddenly move to an app. Therefor, to test the Universal Link, open Notes.app, create a new note and enter/paste the Universal Link you want to test there. You can then click it and get asked whether you want to open this in your app.
1) Sorry, don't have a dev forum link where I read this.
2) Again, sorry, don't have a link right now. Saw this stated at least two times by Apple employees, both cited the Notes trick. Even though they were talking about iOS there, this behaviour is the same on macOS as well.

Deep Linking in iOS - Navigate to Apple Store if app not installed

I need to implement Deep Linking concept without using any third party libraries (Branch and etc..). The link (starts with http/https) will be shared from app through Message, Email or any Social media apps. By tapping on shared link I want to open corresponding app if its already installed on device else it should navigate to the Apple Store to download the app.
I have knowledge on URL schemas but it works only when the app is already installed on device and the schema URL format also be different (like fb:// for Facebook app).
I have also done some R&D on Universal Links but I don't know whether it supports for dynamic links as for me the link will be combination of base URL(static) and referrer key(dynamic). I also need to track the referrer information once the corresponding app is opened like who referred this app (referrer details).
e.g: https://domain.com/ReferrerID
Can you please help me on it. Thanks in advance.
To make it clear on Universal Links in iOS will not take you to Apple Store if app is not installed on device. When you click on a link then Universal Links helps you to open the app if the app is already installed on device else the same link will be going to browse in Safari. When the url browse in Safari then we have to run JavaScript to navigate/redirect to Apple Store.
Yes you can support universal links to your application from iOS 9 or above. You can generate dynamic links and have deferred deep linking also.
Follow this steps its simple Click Here
For the file mentioned in the link you need to add that file in the root of your website which consists of the path valid for deeplinking. And that file should not have any extension.
Then validate your domain at Here.
After that you can add all the domains thing in your associated domain under the project capabilites.

Resources