简体   繁体   English

Android深层链接使用意图不打开应用程序

[英]Android deep link using intent not opening app

I am trying to open an app that I made from mobile chrome browser.我正在尝试打开我从移动 chrome 浏览器制作的应用程序。

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

From this link, I figured that I must use the "intent:" syntax to do the job.从这个链接,我认为我必须使用“intent:”语法来完成这项工作。

However, my app doesn't open.但是,我的应用程序打不开。 Instead, it opens the Google Play Store, but the store just shows the "item not found" page.相反,它会打开 Google Play 商店,但商店只显示“找不到项目”页面。

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?该应用程序必须在 Play 商店上发布才能实现吗?

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. PS)名称“myscheme”和“myhost”只是我为写这个问题而编造的名称。 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,正如 Alexey 在我的帖子中评论的那样,

<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.我仔细检查了官方文档(我帖子上的链接)和我的 chrome 版本(71),所以我不知道为什么 intent:// 语法不起作用。

I guess there were changes on mobile Chrome after version 25 that I missed or couldn't find.我想在第 25 版之后移动版 Chrome 上有一些我错过或找不到的更改。

I just encountered the same problem where linking with Intents did not work but the direct scheme linking did.我刚刚遇到了与 Intents 链接不起作用但直接方案链接起作用的相同问题。 However, I didn't want to use the direct version to have a fallback redirect to the PlayStore.但是,我不想使用直接版本将回退重定向到 PlayStore。

The solution was that the package parameter in the intent link did not have to match the package given in the AndroidManifest.xml.解决方案是 Intent 链接中的包参数不必与 AndroidManifest.xml 中给定的包相匹配。 I was working with a Unity project and had to use the bundle name given in the project setting.我正在处理一个 Unity 项目,必须使用项目设置中给出的包名称。

tl;dr: this is still working in Chrome (v78), but the package parameter is not necessarily the package given in the manifest. tl;dr:这在 Chrome (v78) 中仍然有效,但 package 参数不一定是清单中给出的包。

The package parameter should match your application id (found in build.gradle or your AndroidManifest.xml ) package参数应与您的应用程序 ID 匹配(在build.gradle或您的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.上面的示例代码将包显示为my.test.app.package ,如果这不是您的应用程序包名称或未安装该应用程序,则 Intent 将默认到 Google Play 商店进行搜索。 Similarly, it would be best change the host and scheme parameters to something custom to your app if you haven't already.同样,最好将hostscheme参数更改为您的应用自定义的内容(如果您还没有的话)。

My answer is to open android application from web app using deep linking:我的答案是使用深度链接从 Web 应用程序打开 Android 应用程序:

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.如果列出的应用程序安装在您的手机中,则只有它会打开,否则您必须单独处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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