Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 225
codepeaker Avatar asked Jun 17 '19 09:06

codepeaker


People also ask

What is difference between app link and deep link?

When a user click an URL, it might open a dialog which asks the user to select one of multiple apps handling the given URL. On the other hand, An Android App Link is a deep link based on your website URL that has been verified to belong to your website. When user clicks that URL, it opens your app.

How do I change the app that opens links in Android?

Change Link Opening Settings To change how links open in Android, return to the Default apps page you visited earlier. Here, tap Opening links to review these settings. At the top, you can toggle the Instant apps feature, which allows you to use some apps without actually installing them.

How do I disable deeplink?

You have to have one API which will return boolean to enable or disable the DeepLinking. Based on business, server has to return the response. You need to hit the API on your deep linking Activity and redirect the user to browser in case of disabled deep linking and kill your activity.


1 Answers

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.

like image 120
codepeaker Avatar answered Oct 21 '22 06:10

codepeaker