如何在Chrome中从网页启动instantapp?

时间:2017-09-10 09:51:45

标签: android google-chrome android-intent android-instant-apps

我开发了我的第一个Android即时应用程序,现在可在Google Play上使用 我想从Chrome中的网页调用该应用,但它无法正常工作。

以Wish(www.wish.com)为例,我在Chrome for Android上尝试了以下链接。

1:<a href="https://www.wish.com/">link1</a>

2:<a href="intent://www.wish.com/#Intent;action=com.google.android.instantapps.START;scheme=https;package=com.google.android.instantapps.supervisor;S.browser_fallback_url=https%3A%2F%2Fwww.wish.com%2F;S.android.intent.extra.REFERRER_NAME=https%3A%2F%2Fwww.google.co.jp;launchFlags=0x8080000;end">link2</a>

但上面的链接都不起作用(点击它们只是导航到Wish的网页,但没有即时应用显示),虽然第二个似乎是谷歌在他们的搜索结果页面中使用的。

我还确认可以通过am命令启动该应用,例如:

am start -a com.google.android.instantapps.START -c android.intent.category.BROWSABLE -d https://www.wish.com/

有人知道如何从网页启动即时应用程序吗?

Galaxy S8上的Android 7.0 Chrome for Android 60.0.3112.116

2 个答案:

答案 0 :(得分:0)

我通过在Firebase控制台中创建来自Firebase动态链接https://firebase.google.com/docs/dynamic-links的动态链接找到了此问题的解决方案。 在未安装应用程序时,可以选择将用户发送到即时应用程序。我是从https://developer.android.com/topic/instant-apps/faqs.html(在App链接,深层链接和URL处理部分)

中找到的

Like this

抱歉我的英文。

答案 1 :(得分:0)

只有Firebase Dynamics链接可以从Web打开即时应用程序。你可以很容易生成它manually,但首先检查它在火力控制台是如何工作的。创建测试链接后,请使用“链接详细信息”和“链接预览”。

示例链接:

https://firebase.page.link/?link=https://instant.example.com&apn=package_name&afl=https://example.com

清单中即时应用程序配置的示例:

    <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" />

            <data
                android:host="instant.example.com"
                android:pathPrefix="/"
                android:scheme="https" />
        </intent-filter>

        <meta-data
            android:name="default-url"
            android:value="https://instant.example.com" />
    </activity>