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

7

13

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>
Ripe answered 11/10, 2017 at 6:9 Comment(19)
is your project package example.com? else replace it with your package name also try replacing host with this line android:host="open" do these both and let me knowStalemate
if I replace host with "open" how is it suppose to know from which site I want to be redirected?Ripe
it will redirect for all sites and links as soon as the schema matchesStalemate
ok. my data look now this way - <data android:scheme="https" android:host="open"/> but no result. It redirects me to a web pageRipe
what your app package name?Stalemate
It's com.company.apnameRipe
Let us continue this discussion in chat.Ripe
ok lets discuss it thereStalemate
check this out developer.android.com/training/app-links/deep-linking.html with path prefix you can use http/https schemaStalemate
The same result. It works but not from browser. Did you have success with a http/https scheme?Ripe
Yes, see the second example in that linkStalemate
I tried to put several data into intent-filter, but it still doesn't want to redirect me from example.com. Could you please update your answer with your solution?Ripe
Please replace the intent filter from the example and see if it worksStalemate
<data android:scheme="https" android:host="example.ru" /> <data android:scheme="app" android:host="open.my.app" /> - no resultRipe
Try this , you have missed out path prefix which is crucial in this example if we open wwww.example.com/gizmos it will ask and open the app <data android:scheme="http" android:host="www.example.com" android:pathPrefix="/gizmos" />Stalemate
Works with https schema also, I tried and tested it myselfStalemate
finally. it worked from the very beginning. The problem is - it doesn't work when I click on the link from my email. but if I click this link from (the button on a website) somewhere else - it works. Do you have an idea how to make it work from email letter?Ripe
Glad it worked, try Hyperlink with, link opening in New tabStalemate
I am facing the same issue when add url:scheme with my app name it opens the app but not with https. I have tried the answer given below but it couldn't work. can you please guid me about thisUnmask
S
3

Hi please use the following data and try also refer this doc

<intent-filter>
                <data
                    android:scheme="ou unique scheme(appname,package name)" />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

OR

  <data
                android:scheme="you unique scheme(appname,package name)"
                android:host="www.example.ru"/>
Stalemate answered 11/10, 2017 at 8:17 Comment(2)
How does it differ from the question and how does it solve the problem?Vulcanize
and why is it a selected answer?Civvies
V
4

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://mcmap.net/q/348440/-app-links-intent-filters-in-assetlinks-json-not-working-on-android for App Linking.

Vulcanize answered 14/1, 2020 at 14:59 Comment(0)
S
3

Hi please use the following data and try also refer this doc

<intent-filter>
                <data
                    android:scheme="ou unique scheme(appname,package name)" />

                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

OR

  <data
                android:scheme="you unique scheme(appname,package name)"
                android:host="www.example.ru"/>
Stalemate answered 11/10, 2017 at 8:17 Comment(2)
How does it differ from the question and how does it solve the problem?Vulcanize
and why is it a selected answer?Civvies
O
1

You refer to deep linking but android:autoVerify="true" is used for App linking, so the domain example.com (which you don't own?) is going to get checked for a digital asset links json file. See https://developer.android.com/training/app-links/index.html

For your test to work I'd suggest removing android:autoVerify="true" and adding a subdomain to the host e.g. android:host="www.example.com"

Overlay answered 11/10, 2017 at 6:29 Comment(7)
I changed android:host="example.com" to android:host="www.example.com", deleted autoVerify, but no result, did i miss somth?Ripe
Now it says that connection is not secure. By the way I've added asset links file to the server according to your link but still no resultRipe
Any idea? Do you have at least one app which work with https?Ripe
Where does it say "connection is not secure"?, If it works correctly, you should be presented with the disambiguation dialog to select which app you would like to open the link, I have tested with and works fine. You may have added the asset links file your app server, but it's https://example.com/.well-known/assetlinks.json that's going to be resolved as example.com is the domain your trying to verify.Overlay
I edited mt question like you said, look at it, but it doesn't workRipe
Where has android:host="www.example.ru" come from? Just make sure the clickable link matches the host specified in the manifest.Overlay
Let us continue this discussion in chat.Overlay
B
0

Try this

<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:host="open"
                    android:scheme="example" />
            </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="example.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="example.com"
                    android:pathPrefix="/"
                    android:scheme="https" />
            </intent-filter>
        </activity>
Beth answered 11/10, 2017 at 6:15 Comment(7)
Define "example://" schema in your Branch.io applicationBeth
But what if I have a https scheme?Ripe
yes we are defined both https and http also in intent-filter . It is working my sideBeth
And which Url should I click? example://example.com?Ripe
Create link on Branch.io dashboardBeth
Let us continue this discussion in chat.Ripe
can you open your app with link which has https scheme? or it just works with an example scheme?Ripe
S
0

Just use http. Don't know when the implementation is changed.

But I just tested that using http will make both http and https work.

So change you intent filter by:

<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="http"
    android:host="example.com"/>

</intent-filter>
Semester answered 9/11, 2017 at 7:55 Comment(0)
O
0

youe can also add to it

sub.example.com

<intent-filter android:label="@string/app_name">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="example.com" />
                <data android:scheme="app" android:host="com.example.example" />
            </intent-filter>
Ourselves answered 6/11, 2019 at 8:48 Comment(3)
in my cas it was like this app.mydomain.com/idvalue so it worked with meOurselves
Thanks, I will try.Vulcanize
See the comment at the end of the adding-filters section on duplicate data blocks.Lilly

© 2022 - 2024 — McMap. All rights reserved.