![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
cordova-plugin-mifare-ultralight
Advanced tools
Provides Mifare Ultralight functionality for Cordova-based applications
This plugins lets you interact with Mifare Ultralight NFC tags on Android devices. You can use it to
Include
<plugin name="cordova-plugin-mifare-ultralight" spec="~1.0.0"/>
in the config.xml
of your application.
cordova plugin add cordova-plugin-mifare-ultralight
There is currently only one event emitted by the plugin and that is for found tags. To listen for the event, use this code:
document.addEventListener('mifareTagDiscovered', (tag) => {
alert(`Found tag: ${tag}`);
});
The tag passed as parameter contains tag id as an array of bytes as returned by Tag
class method getId()
.
All methods provided can be found via window.mifare
. If you are using TypeScript, you'll need to add this line on top of each file where you intend to access the plugin:
declare const window;
Available methods:
mifare.enabled(success, failure)
Checks for availability of NFC on device. If success callback is called, NFC is available and enabled. If failure callback is called instead, there is string parameter available telling whether device does have no NFC at all (NO_NFC
) or if it just disabled (NFC_DISABLED
).
window.mifare.enabled(() => alert('NFC enabled'), status => alert(status));
mifare.connect(success, failure)
Connects to tag that was found. This is usually called inside the event handler for mifareTagDiscovered
.
document.addEventListener('mifareTagDiscovered', () => {
window.mifare.connect(() => alert('Connected'), err => alert(`Couldn't connect because: ${err}`));
});
mifare.disconnect(success, failure)
Disconnects from the tag that was connected.
window.mifare.disconnect(() => alert('Disonnected'), err => alert(`Couldn't disconnect because: ${err}`));
mifare.isConnected(success, failure)
Checks if there is a connection to a tag.
window.mifare.isConnected(() => alert('Connected to tag'), () => alert('Not connected'));
mifare.read(page, success, failure)
Tries to read the page specified. Parameter page
should be a number. If reading succeeds, the success callback will be called with data object as parameter. To access the actual data as string use .data
for this object.
window.mifare.read(4, (response) => alert(response.data), err => alert(`Reading failed because ${err}`));
mifare.write(page, data, success, failure)
Tries to write the data to the page specified. Parameter page
should be a number. Parameter data
should be an array of 4 strings of 2 characters (4 bytes).
window.mifare.write(4, ['AA', 'BB', 'CC', 'DD'], (response) => alert('Write ok'), err => alert(`Writing failed because ${err}`));
mifare.unlock(pin, success, failure)
Tries to unlock the tag. Parameter pin
should be a number.
window.mifare.unlock(0x1234, (response) => alert('Unlocked successfully'), err => alert(`Couldn't unlock because ${err}`));
Q: Why is there no version to iOS or Windows Phone?
A: This plugin was written for my own needs to interact with Mifare Ultralight in Cordova-based application on Android.
iOS couldn't even be supported as Apple only permits its own wallet application to use the NFC.
Windows Phone could be supported if someone wrote the necessary native code. I might be able to help a little with this but won't be implementing this all by myself.
Q: Are there Ionic native bindings for easier usage?
A: Not yet unfortunately. It is something on the todo list for sure, though.
Q: Why is there no event for tag lost?
A: I would be happy to take in a Pull Request for this. It seemed somewhat cumbersome to implement.. Maybe at some point I will find the motivation to add it.
This plugin is heavily influenced by the excellent work done on PhoneGap NFC Plugin. Thank you for the effort you have put into it over the years.
FAQs
Provides Mifare Ultralight functionality for Cordova-based applications
The npm package cordova-plugin-mifare-ultralight receives a total of 35 weekly downloads. As such, cordova-plugin-mifare-ultralight popularity was classified as not popular.
We found that cordova-plugin-mifare-ultralight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.