chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 559 forks source link

Recieving an intent using webintent tries to create multiple listeners #136

Closed JohnMcLear closed 8 years ago

JohnMcLear commented 9 years ago

This is a bit of a tricky one to explain so bare with me..

If I launch my app directly using an intent NFC functionality works fine.

If I launch my app THEN remove focus from that app (put it in the background), then open a browser and fire an intent (open web browser and go to share option) then when I try to do an NFC event it just takes me to the first page of my app (as if an error has fired but because phonegaps error handling sucks I'm completely lost)

I use the webintent plugin to handle intents, this is working fine, I can see them being hjandled fine.

I see two instances of : Initialized the NfcPlugin

I am pretty sure this is due to the fact that Cordova is trying to bring up a second instance of the NfcPlugin.

My source code is available at: https://github.com/mclear/NFC_Ring_Control/tree/better-intent-support

I'd love a fresh pair of eyes to look at this with me because I think it may be something and nothing I'm just having a brain fart.. :(

JohnMcLear commented 9 years ago

Also see https://github.com/JohnMcLear/NFC_WebIntent for a simplified example of the error

don commented 9 years ago

Based on your example I think this is behaving as intended.

When a NFC tag is scanned, the WebIntent.java grabs the Intent first, then the NfcPlugin.java get the intent.

WebIntent.java tries to get intent.getDataString(), which is Null for android.nfc.action.TECH_DISCOVERED

screen shot 2014-09-10 at 6 29 09 pm

The easiest solution might be to fork the webintents plugin and have it ignore all NFC intents.

JohnMcLear commented 9 years ago

I will see if I can get the issue resolved in the webIntent plugin.

The weird thing is that NFC functionality is breaking, surely that's not desirable behavior for your plugin?

JohnMcLear commented 9 years ago

Any chance you can do a quick form and test to see if it works please? I'm out of my depths in Java ;\

Happy to test it though :)