chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 559 forks source link

Windows Phone 8 never really discards NFC listener properly and re-assigning doesn't seem to work properly #115

Closed JohnMcLear closed 8 years ago

JohnMcLear commented 10 years ago

If I have a page..

My HTML files Index.html createAction.html

I browse to createAction.html, do addNdefListener, write some tags then do a window.location = index.html then re-visit createAction.html the second time the addNdefListener fails..

Initialized the NfcPlugin is only output..

I think if there is a way I can check before I try to do addNdefListener if it's already been executed that would help.. Can you replicate this issue on WP by trying to add addNdefListener twice?

It's very probable my code is to blame here, it works fine on Android tho..

JohnMcLear commented 10 years ago

Actually after the first write event, no further events trigger, I don't need to change the page.. ehhhhh confused..

JohnMcLear commented 10 years ago

it appears that after a write ndefListener is no longer functioning for some reason...

JohnMcLear commented 10 years ago

gonna checkout a clean repo and see if I can replicate..

don commented 10 years ago

I use single page apps for most phonegap stuff, especially NFC. When you reload the page, you need to make sure cordova is initializing correctly.

Is the ProximityDevice defined the 2nd time you load the plugin? https://github.com/chariotsolutions/phonegap-nfc/blob/master/src/windows-phone-8/NfcPlugin.cs#L34 Step through in the VisualStudio debugger or check the log output.

JohnMcLear commented 10 years ago

Thought I was going insane, turns out I wasn't.. After a single write event future events fail..

replicate with the following code..

onDeviceReady: function() {
  app.receivedEvent('deviceready');
  nfc.addNdefListener(function(nfcEvent){
    nfc.write([ndef.uriRecord("http://test.com")], function(){
      console.log("written");
    },
    function(e){
      console.log("NOPE",e);
    });
  });
},

So yeah, can't believe I never spotted this bug before, weird ey!

JohnMcLear commented 10 years ago

Not you never get "NOPE", the event only fires once..

JohnMcLear commented 10 years ago

Just a gentle nudge on this :)

don commented 8 years ago

This works on windows platform. Tested with Lumia 640 running Windows Phone 8.1 Update 2.

Not planning on fixing Windows Phone 8 / SilverLight version.

@JohnMcLear if your still seeing a problem re-open with an updated example.