- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Estou com um problema em uma função do plugin PhoneGap-NFC no Intel XDK.
function nova_pulseira(cli_nova_id) {
nfc.addTagDiscoveredListener(function(nfcEvent){
var tag = nfcEvent.tag;
var tagId = nfc.bytesToHexString(tag.id);
if(tagId !== 0) {
nova_pulseira_input(cli_nova_id, tagId);
} else {
myApp.alert('Erro na leitura da pulseira.','Aviso');
}
});
}
A função nfc.addTagDiscoveredListener é utilizada para fazer a leitura da TAG NFC, quando ocorre nfcEvent.
Na primeira leitura ela funciona normalmente, porém quando faço uma segunda leitura, a funçãonfc.addTagDiscoveredListener é aplicada 2 vezes, na terceira leitura, ela é aplicada 3 vezes, e assim sucessivamente.
A única maneira que encontrei para "parar" essa função, é utilizando location.reload(); porém ele retorna para a página inicial do Aplicativo, sendo que o ideal seria ativar uma subpage.
Gostaria, de alguma forma, que a função nfc.addTagDiscoveredListener seja desabilitada após aplicar a função nova_pulseira_input(cli_nova_id, tagId);
PS: Já utilizei
--> return false;
--> $.each(nfc, function(){ this.reset(); });
--> intel.xdk.cache.clearAllCookies();
--> $.ajaxSetup({cache: false});
Obrigado pela ajuda de todos...
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rafeal S. wrote:
I have a problem in a function PhoneGap-NFC plug-in Intel XDK.
function nova_pulseira (cli_nova_id) { nfc.addTagDiscoveredListener (function (nfcEvent) { var tag = nfcEvent.tag; var = TagID nfc.bytesToHexString (tag.id); if (TagID! == 0) { nova_pulseira_input (cli_nova_id, TagID); } Else { myApp.alert ( 'error in reading the bracelet.' 'Notice'); } }); }The nfc.addTagDiscoveredListener function is used for reading NFC TAG when occurs nfcEvent. In the first reading it works normally, but when make the second reading, the funçãonfc.addTagDiscoveredListener is applied 2 times, in the third reading, it is applied 3 times, and so on.
The only way I found to "stop" this function is using location.reload (); but he returns to the Application home page, and the ideal would be to activate a subpage.
I would, somehow, that nfc.addTagDiscoveredListener function is disabled after applying the nova_pulseira_input function (cli_nova_id, TagID);
PS: I've used -> Return false; -> $ .each (Nfc, function () {this.reset ();}); -> Intel.xdk.cache.clearAllCookies (); -> $ .ajaxSetup ({Cache: false});Thanks for the help of all ...
I recommend you make a simpler event handler that generates console.log() messages and prints the object information you receive. Avoid using an alert to debug the issue. Alerts can interfere with normal processing and cause problems like what you are seeing.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page