Search code examples
androiddeep-linkingandroid-app-links

How to Disable Android App links if user is on website?


Let us say there is a website https://www.example.com and we are listening to https://www.example.com/product in Android App with following intent filter

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data
        android:host="www.example.com"
        android:pathPrefix="/product"
        android:scheme="https" />
</intent-filter>

And the file assetlinks.json is also hosted on example.com

The Android App links are working fine as expected.

Now, if the user went to browser and open example.com and the user clicks on https://example.com/product which will be opened in app but we want to block app from opening only if the user is on our website

Any help will be appreciated.


Solution

  • After looking a lot, The only workaround i was able to find to open web instead of app is redirection from web -> app (redirection logic) -> website.

    An important thing, I noticed is that the App is never invoked if the page is developed in React or Angular and is not based on JSP. In our case, We were using Tomcat server, So whenever user navigate to different page, The Android System get to know that a new page is opened in browser, which makes Android System to open Android App if listening to that url specified in the intent filter. However, this doesn't happen if the page is designed in React and Angular.

    Now, this is really difficult for me to describe as i am not a web developer and this is what the web developers told and i experienced with both JSP and React pages.