Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android. Deep linking doesn't work with http/https scheme

I added a deep linking to my Android app this way:

<activity
        android:name=".views.DeepLinkingActivity"
        android:exported="true">
        <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:scheme="https"
                android:host="example.com"/>
        </intent-filter>
    </activity>

When I click on https://example.com I get redirected to the web site.

When I change android:scheme="https" to android:scheme="appscheme" it works and it redirects me to my app.

How to force my app to be opened via https scheme?

UPDATE

I added a subdomain and it still doesn't work.

<activity
        android:name=".views.DeepLinkActivity"
        android:exported="true">
        <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="https"
                android:host="www.example.ru"/>
        </intent-filter>
    </activity>
like image 998
Rainmaker Avatar asked Oct 11 '17 06:10

Rainmaker


People also ask

How does deeplink work on Android?

In Android, a deep link is a link that takes you directly to a specific destination within an app. The Navigation component lets you create two different types of deep links: explicit and implicit.

What is the difference between deep linking and deferred deep linking?

In the context of mobile apps, deep linking consists of using a uniform resource identifier (URI) that links to a specific location within a mobile app rather than simply launching the app. Deferred deep linking allows users to deep link to content even if the app is not already installed.

How do I create a deeplink URL?

Click Add Navigation Icon, then select Add a Web URL. Give it a name. Click Show URL options, then select "Deeplink app URL." Add your deeplink URL to the textbox labelled "Deeplink app URL" and a backup link to the textbox labelled "URL."


1 Answers

Thanks to veritas1 I removed android:autoVerify="true" from https-scheme. I also changed the scheme from https to http. (You can read about autoVerify).

So, currently have two different schemes:

<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:host="your-site.com"
        android:pathPrefix="/"
        android:scheme="http"
        />
</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="your-site.com"
        android:pathPrefix="/"
        android:scheme="myapp"
        />
</intent-filter>

When clicking on a link myapp://your-site.com/... an application will be opened. When clicking on http://your-site.com/... Chrome browser will offer to open in the application or another browser, while other mobile browsers ignore this and try to open themselves.

UPDATE

See https://stackoverflow.com/a/60342565/2914140 for App Linking.

like image 198
CoolMind Avatar answered Sep 18 '22 16:09

CoolMind