NFC即时应用

时间:2017-10-26 07:50:38

标签: android nfc deep-linking branch.io android-instant-apps

我试图通过NFC打开即时应用程序。

我的AndroidManifest.xml中有类似下面的内容

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

            <data android:scheme="https" />
            <data android:scheme="http" />
            <data android:host="example-refresh.herokuapp.com" />
        </intent-filter>

当从链接转到https://example-refresh.herokuapp.com(显然示例链接)时,单击即时应用正确加载。当从nfc标签打开该链接时,浏览器就会加载。我已尝试让nfc打开AARhttps://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar)这会导致在未安装应用时播放商店链接打开并且应用正确地从nfc打开它已安装。如果我在nfc上有其他东西,那么它显示了消除歧视的选项,那么我可以为浏览器选项选择即时应用程序,但我希望它默认为即时应用程序。

是否有一些我缺少的东西可以让nfc标签加载即时应用?我也试过使用分支,但没有运气。

1 个答案:

答案 0 :(得分:0)

即时应用的allowed permissions集合非常有限,而NFC不在其中。因此,任何与NFC相关的意图均无效。此外,您在清单上定义的任何内容仅在安装应用程序后才有效。对于即时应用程序显然不是这样。当您将APK上传到Play商店时,Google会为android.intent.action.VIEW的意图编制索引,以便它们使即时应用生效。

因此,当您扫描NFC时,这是android.nfc.action.NDEF_DISCOVERED的意图,因此您的应用程序将无法启动

但是,您仍然可以使其正常运行。您应该使用通常在Play商店中将即时应用程序的链接写到NFC标签上,而不使用通常用于启动即时应用程序的链接。

https://play.google.com/store/apps/details?id=<package_name>&launch=true

选中https://developer.android.com/distribute/marketing-tools/linking-to-google-play#Instant