NFC即时应用 [英] Instant Apps with NFC

查看:327
本文介绍了NFC即时应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过NFC打开即时应用。

I'm trying to get an instant app to be opened via NFC.

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

I have something like the below in my 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打开 AAR https://developer.android.com/guide/ topic / connectivity / nfc / nfc.html#aar ),这会导致未安装应用时打开Play商店链接,而在安装后会从nfc正确打开应用。如果我在nfc上还有其他内容,以便显示明确的选项,则可以为浏览器选项选择即时应用程序,但是我希望它默认为即时应用程序。

When going to https://example-refresh.herokuapp.com (example link obviously) from a link click the instant app loads correctly. When opening that link from an nfc tag the browser just loads. I've tried also having the nfc open an AAR (https://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar) this results in the play store link opening when the app isn't installed and the app correctly opening from the nfc when it is installed. If I have something else on the nfc so it shows the disambigious options then I can select instant app for the browser option, but I would like for it to default to instant app.

我是否缺少获取nfc标签以加载即时应用程序的功能?我也试过使用分支,但是没有运气。

Is there something I'm missing to get an nfc tag to load an instant app? I've also tried using branch, but with no luck.

推荐答案

即时应用程序的允许的权限和NFC不在那个集合中。因此,任何与NFC相关的意图均不起作用。此外,您在清单上定义的任何内容仅在安装应用程序后才有效。对于即时应用程序显然不是这样。当您将APK上传到Play商店时,Google会为 android.intent.action.VIEW 意向编制索引,以便他们可以使即时应用生效。

Instant apps have a very limited set of allowed permissions and NFC is not in that set. Thus any NFC related intent will not work. Besides, whatever you define on your manifest only works when your app is installed. Which obviously is not the case for instant apps. Google does index the android.intent.action.VIEW intents when you upload your APK to Play Store, so they can make instant app works.

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

So when you scan an NFC, it is an android.nfc.action.NDEF_DISCOVERED intent, and therefore your app won't be launched

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

However, you still can make it work. Instead of using the link you would normally use to launch your instant app, you should write the link to your instant app on the Play Store to your NFC tag.

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

检查 https:// developer。 android.com/distribute/marketing-tools/linking-to-google-play#Instant

这篇关于NFC即时应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆