Closed JohnMcLear closed 8 years ago
Actually after the first write event, no further events trigger, I don't need to change the page.. ehhhhh confused..
it appears that after a write ndefListener is no longer functioning for some reason...
gonna checkout a clean repo and see if I can replicate..
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.
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!
Not you never get "NOPE", the event only fires once..
Just a gentle nudge on this :)
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.
If I have a page..
My HTML files Index.html createAction.html
I browse to createAction.html, do
addNdefListener
, write some tags then do awindow.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..