I've already been able to setup deep links (universal links), whenever a link to my site (https://app.example.com) is clicked, it automatically opens the app. If its from slack, messenger or another website. The problem is, if I'm inside app.example.com and I create a link to open app.example.com, it doesn't open the app.
I cant seem to find any documentation to address this problem and I'm not sure if its even allowed, but basically this is the flow that I want to achieve:
But as mentioned, step 5 doesn't open the app even if I placed a link-button (as expected on how universal links work), it just redirects within the browser.
Any solution? I need to be able to handle android and iOS, as well as not interfere with PC browsers. If needed, I code using Ionic v6.
Thank you!
As far as I know, this is expected behavior.
The reason is,
Let's say your user actually chose to navigate to your website instead of the application. Since the user is already browsing the website, we can assume the user will keep browsing the website, otherwise, he or she would be inside the app already.
This user might navigate to different pages on your website. If deep links try to send users to the app every time, it would be a terrible UX.
If your intent is to always open the app anyways, using a custom URI scheme is the way to go.
it's a bit late, but at least leave it here for other guys who are looking for the solution.
In our team, we met the same issue recently. As @selcuk-sahin said, it is indeed the expected behavior. But there are some ways to overcome it.
Solution 1: To use a subdomain for deep links If a user navigates in the same domain in the browser, https://app.example.com then neither Chrome nor Safari allows an application to intercept the request and to be opened. But if the user navigates to https://subdomain.app.example.com then it is the change of the domain and your app will be opened if linked to that subdomain.
So just on step 5 use the new subdomain:
https://subdomain.app.example.com
There is also a recommendation about it on the official apple doc https://developer.apple.com/documentation/technotes/tn3155-debugging-universal-links#Use-universal-links-on-your-site
Solution 2: Use custom URI schemes. For example:
openapp://app.example.com
And for example in AndroidManifest.xml subscribe to it:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="openapp"
android:host="app.example.com" />
</intent-filter>
Disadvantage of this solution is that if your app is not installed this approach will fail.
Solution 3(only Android) There is also one more way, specifically for Android is to use a predefined system custom URL scheme:
android-app://com.example.app/
In you webpage you will have something like this:
<a href="android-app://com.example.app/
#Intent;action=com.example.CUSTOM_ACTION;end" target="_blank">Open app</a>
And in the app:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="android-app" />
<data android:host="com.example.app" />
</intent-filter>
Here's the official android doc: https://developer.android.com/reference/android/content/Intent#URI_ANDROID_APP_SCHEME
If you want to find out more about this topic you can check my article: https://medium.com/@oleg7green/the-specific-case-of-app-links-on-android-ios-apps-47a0455f8892
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