Comments (2)
Hello,
As I was testing this possibility, I think I found the answer : NO.
Consider these listeners :
nfc.addMimeTypeListener(
'app/bt',
app.firstCallback,
function() {
console.log( "Listening for NDEF mime tags with type app/bt." );
},
function(){
throw new appError( "Error establishing NDEF MimeType listener" );
}
);
nfc.addMimeTypeListener(
'app/ty',
app.secondCallback,
function() {
console.log( "Listening for NDEF mime tags with type app/ty." );
},
function(){
throw new appError( "Error establishing NDEF MimeType listener" );
}
);
Adding 2 MimeType listeners in a deviceReady function executes the 2 callback functions when detecting a tag containing a 'app/bt' MimeType record, and no 'app/ty' MimeType record.
Do you think I misunderstood anything, or is it the 'normal' behaviour of the plugin ?
from phonegap-nfc.
The plugin was designed to have registerMimeType called one time, but it can be called for multiple mime types.
phonegap-nfc doesn't pass return values through the success callback like may phonegap plugins (this is a legacy issue from phonegap 0.9.x)
nfc.addMimeTypeListener registers event listener for javascript ndef-mime events
var nfc = {
addMimeTypeListener: function (mimeType, callback, win, fail) {
document.addEventListener("ndef-mime", callback, false);
cordova.exec(win, fail, "NfcPlugin", "registerMimeType", [mimeType]);
},
...
With Android 4.x is you use the same listener for multiple mimetypes, it appears to work OK and the listener is only called once.
nfc.addMimeTypeListener("text/json", onNfc, success, failure);
nfc.addMimeTypeListener("text/demo", onNfc, success, failure);
If you use different listeners BOTH listeners are called every time.
nfc.addMimeTypeListener("text/json", onNfc, success, failure);
nfc.addMimeTypeListener("text/demo", onNfc2, success, failure);
This is because the native Android code registers a filter for the mime type but throws the same ndef-mime javascript event for every tag.
from phonegap-nfc.
Related Issues (20)
- Does this plugin works in iOS 15.2?
- NFC reader
- Android 12 - Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent HOT 25
- Build failed when installing a Plugin in Phonegap (NFC)
- Support for ISO18092 tags in iOS
- Writing NFC Tag didn't succeeded every time in Quasar Cordova mobile App
- android NFC Card HOT 1
- NFC scanning not working IOS HOT 7
- SerialNumber not being retrieved on iOS HOT 1
- Android 12 SDK not fire scan event HOT 3
- Ionic NFC on Android 12 Crushing the App HOT 8
- Ionic Android 13 makeReadOnly java.io.IOException HOT 3
- Does not work with Xcode 14.3 and iOS 16.4 HOT 3
- Does this plugin support BAC ( Basic Access Control ) to read NFC Chip on ePassport ? HOT 1
- NFC Writting Error - Only one tag technology can be connected at a time HOT 6
- Ionic capacitor targetsdk 33 app crash with plugin is installed without nfc plugin work works ok HOT 28
- On ios while reading tag give error 203. "System resources unavailable HOT 7
- NFC Tag Writing Issue HOT 1
- The first two Characters are getting trimmed
- Android Api 34 error Android 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phonegap-nfc.