Android deep link working only in some websites
Asked Answered
H

1

8

I am using app indexing in my app but sometimes it is not receiving correctly the intents from Chrome.

If I open the link from my production website, it is opened by chrome. So I have created a testing site which has the same code. However, in this case, my app is opening the deep link correctly.

I can't find any explanation as it is using the same code in the web (but in diferent sites) and the same Android app.

This is my 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:scheme="https" android:host="soriabus-web.appspot.com" android:pathPrefix="/" />
        </intent-filter>

This is the html code in my button:

<a href="https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados/true"
"type="button"
role="button"
class="btn btn-primary">
Abrir Soria Bus
</a>

If I open the link in this address (production), it opens Play Store (the end of the link is a redirect to Google Play):

https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados

If I open the link in this other address (test), it opens my app correclty:

https://central-splice-128620.appspot.com/parada/1/plaza-mariano-granados

I don't understand why the links are handled differenty. Thank you.

EDIT:

Is it because I am following a link inside the same site?

https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados => https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados/playstore

Horned answered 30/10, 2016 at 22:28 Comment(0)
D
2

If you tested it in Android browser(the default browser until Android 4.2), it works. So it seems it's a feature from Android chrome browser. referred from here: https://developer.chrome.com/multidevice/android/intents

And Chrome doesn’t launch an external app for a given Intent URI in the following cases.

When the Intent URI is redirected from a typed in URL.
When the Intent URI is initiated without user gesture.

In your case, it's the same as a typed url.

You should try the intent:// syntax from above page which is recommended by Google, if you want to open it from chrome.

Dysart answered 8/11, 2016 at 2:28 Comment(8)
Isn't Chrome the Android default browser?Horned
Or I could reask my question as "why is my case the same as type an url if my action is pressing a button?"Horned
@JavierDelgado Sorry, it named Android browser, the default browser before Android 4.2, I edited this part in my answer. could you please try the intent way which I mentioned?Dysart
I have changed my button code to the one in the example webpage: <a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end" type="button" role="button" class="btn btn-primary">Abrir Soria Bus</a>. It works for Chrome and Android browsers in my phone, but it doesn't work it desktop (with the fallback_url). I raise "scan GET (canceled)"Horned
And I still don't understand why does it work with chrome for a different webpage.Horned
@JavierDelgado As I know for deeplink, you should automatically return different link from server side depend on the client type, since PC, Android, and iOS use different links.Dysart
But S.browser_fallback_url should work in Chrome in desktop, right?Horned
@JavierDelgado fallback url is for the case your app is not installed on the device, and the document is for Android chrome, not the PC chrome, it's totally different.Dysart

© 2022 - 2024 — McMap. All rights reserved.