Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instant Apps with NFC

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

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>

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.

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.

like image 532
Ryan C Avatar asked Oct 26 '17 07:10

Ryan C


People also ask

Can an NFC tag open an app?

By using an NFC tag, many different operating steps on the smartphone can be shortened, using so-called shortcuts. All it takes is a quick contact of the tag with an NFC-enabled iPhone. An example: Use an NFC tag to open the Maps app directly when contacting the iPhone.

Can you download an app for NFC?

Download and install the “NFC Easy Connect” app on your Android smartphone. Search for “NFC Easy Connect” at Google Play™ Store. The app may not be downloadable in some countries/regions. Install the “NFC Easy Connect” app on the smartphone by following the on-screen instructions.

What are examples of instant apps?

5 examples of Android instant apps you can trySkyscanner: flights and hotels: access to cheap tickets, accommodation and car rental, with an alert system. NYTimes Crossword: crosswords of The New York Times. Buzzfeed: Quiz, Tasty, News: full access to the platform app.

What is instant apps on Google Play?

A Google Android instant app is a small software program that enables end users to test out a portion of a native Android app without installing it on a device. Instant apps, although they run like local apps, are native containers with access to a device's hardware.


1 Answers

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.

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

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

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

like image 124
André Oriani Avatar answered Oct 23 '22 05:10

André Oriani