Skip to content Skip to sidebar Skip to footer

Chariotsolutions Phonegap-nfc Plugin Intent

I use the phonegap-nfc plugin from chariotsolutions. Reading a NFC tag while the app is running is no problem. I registered the app for intents so it starts when the app is in back

Solution 1:

You need to add a mime type listener to get the nfcEvent fired by the intent when the application launches.

You can use the same event handler you are using for the NDEF listener, everything is the same except for the event type. You don't need to specify a mime type.

nfc.addMimeTypeListener("", app.onNfc, success, failure);

This is a bit odd, but the way it works because of how events are fired in the plugin implementation.

Solution 2:

That plugin listens for NFC events, but it only notifies the JS callbacks that have been previously registered from Javascript code. So your web page must have been loaded in the webview first, then cordova's load event must have been fired, and only then you can register callbacks. So I think the plugin alone does not solve your problem.

To do what you need, you could add NFC detection capabilities to the Web Activity (using Java API), then store the readed tag info in persistence (again using Java), and then create a custom Cordova plugin to read this info from javascript in your JS entry point (for instance in the "deviceready" event callback).

Post a Comment for "Chariotsolutions Phonegap-nfc Plugin Intent"