This plugin for Cordova/Phonegap is a WIP port of the excellent react-native-nfc-manager module for React Native.
The API of the plugin is almost the same.
For now, only iOS and Android are supported.
PRs are welcome. You can also hire me to work on this plugin and develop it more.
We assume you have a setup Cordova / Phonegap project already.
cordova plugin add https://github.com/zabojad/cordova-nfc-manager.git
This is a WIP project for now but here is a example of use of this plugin:
You should first call NfcManager.start()
before calling any other method of the plugin:
NfcManager.start();
Request tech:
let tech = NfcManager.NfcTech.Iso15693IOS;
NfcManager
.requestTechnology(tech,{ alertMessage: 'Ready to scan tag' })
.then(
function(resp){
console.log('got tech: '+JSON.stringify(resp));
}
);
Get Tag:
NfcManager
.getTag()
.then(function(tag){
console.log('tag: '+JSON.stringify(tag));
});
Use of the ISO 15693 API:
NfcManager.Iso15693HandlerIOS
.getSystemInfo(NfcManager.Nfc15693RequestFlagIOS.HighDataRate)
.then(function(resp){
console.log('SystemInfo: '+JSON.stringify(resp));
});
ISO 15693 readSingleBlock:
NfcManager.Iso15693HandlerIOS
.readSingleBlock({
flags: NfcManager.Nfc15693RequestFlagIOS.HighDataRate,
blockNumber: 0,
})
.then(function(resp){
console.log('readSingleBlock: '+JSON.stringify(resp));
});
ISO 15693 extendedWriteSingleBlock:
NfcManager.Iso15693HandlerIOS
.extendedWriteSingleBlock({
flags: NfcManager.Nfc15693RequestFlagIOS.HighDataRate,
blockNumber: 2,
dataBlock: [12,34,56,78]
})
.then(function(){
console.log('extendedWriteSingleBlock done');
});
More documentation to be written...