简体   繁体   中英

Android deep link using intent not opening app

I am trying to open an app that I made from mobile chrome browser.

https://developer.chrome.com/multidevice/android/intents

From this link, I figured that I must use the "intent:" syntax to do the job.

However, my app doesn't open. Instead, it opens the Google Play Store, but the store just shows the "item not found" page.

I would love to know if I'm doing anything wrong.

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

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

            <data android:scheme="myscheme" android:host="myhost" android:path="/"/>
        </intent-filter>

This is the intent filter that I wrote.

var androidIntentUrl = 'intent://myhost/#Intent;scheme=myscheme;package=my.test.app.package;end';

if(!isIOS && isChromeAndBiggerThanVer25()) {
        location.href = androidIntentUrl;
}

And this is what I wrote on the web.

Must the app be released on Play Store to make this happen?

I don't quite understand the whole stuff yet.

I want to know what's wrong.

PS) The names "myscheme" and "myhost" are just names that I made up for writing this question. The actual names in my code match those written in my project settings and all, including the package name.

As Alexey commented on my post,

<a href="myscheme://myhost/some/other/parameters">

worked just okay for me.

I double checked the official document (the link on my post) and my chrome version (which is 71), so I have no idea why the intent:// syntax did not work.

I guess there were changes on mobile Chrome after version 25 that I missed or couldn't find.

I just encountered the same problem where linking with Intents did not work but the direct scheme linking did. However, I didn't want to use the direct version to have a fallback redirect to the PlayStore.

The solution was that the package parameter in the intent link did not have to match the package given in the AndroidManifest.xml. I was working with a Unity project and had to use the bundle name given in the project setting.

tl;dr: this is still working in Chrome (v78), but the package parameter is not necessarily the package given in the manifest.

The package parameter should match your application id (found in build.gradle or your AndroidManifest.xml )

The sample code above shows package as my.test.app.package , if this is not your app package name or if the app is not installed, the intent will default to the Google Play Store to search for it. Similarly, it would be best change the host and scheme parameters to something custom to your app if you haven't already.

My answer is to open android application from web app using deep linking:

Flipkart     - <a href="flipkart://app"> Open Flipkart!  </a>
WhatsApp     - <a href="whatsapp://app"> Open WhatsApp!  </a>
Clash Royale - <a href="clashroyale://app"> Open Clash Royale!  </a>
FaceBook     - <a href="fb://app"> Open FaceBook!  </a>

If the listed application is installed in your mobile then only it will open or you have to handle the case separately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM