Can the Web NFC api be used in Progressive Web Applications?
Asked Answered
F

2

15

I need to implement NFC (near field communication) in a PWA (progressive webapplication)

Every browser I have tested (Chrome MacOSX, Safari MacOSX, Safari iOS, Chrome for android) does not include the navigator.nfc object in navigator and it seems impossible to make use of this API: https://w3c.github.io/web-nfc/#conformance.

Is it possible to use NFC in any way in a PWA? Or do I have to develop a native application for this functionality?

Fluoro answered 2/7, 2018 at 11:3 Comment(5)
"Every browser I have tested " could you be more specific? For example Chrome 67 has navigator.nfc. Anyway if NFC is not supported by a target browser it is highly unlikely you could polyfill it.Rhesus
I have updated the description, for me chrome 67 is returning undefined when querying the console for navigator.nfc, though it might be because I am using macOS?Fluoro
Might be. I was testing on win8.1.Rhesus
groups.google.com/a/chromium.org/forum/#!topic/blink-dev/… " Support for Mac would be implemented as soon as NFC API is supported by the platform."Rhesus
ah.. well, I have tried to find the nfc object using the remote inspector in google chrome and safari. And on mobile (iOS latest safari / galaxy s9 chrome v67) it is not showing up in the navigator either.Fluoro
C
22

Web NFC API is available only in Chrome for Android and that too when a flag is enabled(try about:flags) enabled.

Unless you are targeting your app for some internal corporate app where you can set the flag in all targeted users browser, I would recommend go with native code or wrapper(cordova or have a native app send in the details via web sockets)

This API is not making much progress since 2015 and so you can expect no magic to happen anytime soon. So don't rely on this API if you are targeting this for a critical app, especially when you cant control the end users browser settings.

Catsup answered 2/7, 2018 at 19:45 Comment(0)
I
2

From chrome 81 you can use NFC https://blog.chromium.org/2020/02/chrome-81-near-field-communications.html

Isom answered 6/5, 2020 at 13:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.