Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can PWA access android's NFC capabilities - in 2019?

We are developing PWA for our app because it's capable of 99% of our needs , however we do need NFC reading capabilities (not writing) and we would hate to abandon PWA and go Native just for this 1 thing

Our purpose for NFC is for reading the serial only. In fact we dont need fancy NFC functions. We just have a text field where the NFC code should be typed in, kinda like how barcode readers work (keyboard emulation)

Is this possible with PWA today?

like image 639
BrownChiLD Avatar asked Apr 06 '19 03:04

BrownChiLD


2 Answers

The Web NFC API has a draft status at W3C. However, it seems to be the case that Chrome for Android has support for NFC, but only in experimental modus.

This means that currently, if you would release your application today, NFC will not generally be supported. However, the fact that Google has it available in experimental modus, seems to indicate it will be more widely available soon.

You can check the status here

like image 87
TmKVU Avatar answered Oct 23 '22 12:10

TmKVU


For in-house solutions (or solutions where you have full control over the device) you can do it without NFC api in browsers (at least until it is available).

You will need to install Tasker app (paid, about 3 USD), which can create NFC read trigger, which then can open url like yourapp.com/{nfc_uid}. If YourApp is installed as PWA, you can select to open the url in the app instead of browser. This way it will look like the PWA is reading the NFC tag.

To make it work: 1. Install Tasker 2. Add new -> Event -> Network -> NFC Tag. Leave field blank and confirm (or just press back button) 3. Add new Task to this trigger: System -> Send intent Action: android.intent.action.VIEW Data: http://yourapp.com/%nfc_id Extra: com.android.browser.application_id:yourapp Target: Activity 4. Save

The reason we are not doing it using Task "Open url" is because we do not want to open new tab each time it is triggered.

If you have everything right and you scan NFC tag, your app should load with the NFC UID in url.

like image 45
Martin Brabec Avatar answered Oct 23 '22 11:10

Martin Brabec