Comments (16)
Is this something that is being worked on?
from phonegap-nfc.
Not actively. Do you need it? Which platform?
from phonegap-nfc.
I'm working on a project in which we're considering using PhoneGap and this NFC plug-in as a part of the solution. We want to be able to lock tags. Right now Android seems like the platform to go with since we don't have any interest in Blackberry, WP8 doesn't support locking tags and iOS doesn't even support NFC.
Make read-only support for Android could very easily be added (see code below). However, is seems like the plug-in code base might be undergoing some big changes. Thus I'm not sure if you'd like me to try and commit these addition.
NfcPlugin.java
private void eraseTag(CallbackContext callbackContext) throws JSONException {
Tag tag = savedIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
NdefRecord[] records = {
new NdefRecord(NdefRecord.TNF_EMPTY, new byte[0], new byte[0], new byte[0])
};
writeNdefMessage(new NdefMessage(records), tag, callbackContext, false);
}
private void writeTag(JSONArray data, CallbackContext callbackContext) throws JSONException {
if (getIntent() == null) { // TODO remove this and handle LostTag
callbackContext.error("Failed to write tag, received null intent");
}
Tag tag = savedIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
NdefRecord[] records = Util.jsonToNdefRecords(data.getString(0));
boolean makeRealOnly = data.optBoolean(1);
writeNdefMessage(new NdefMessage(records), tag, callbackContext, makeRealOnly);
}
private void writeNdefMessage(final NdefMessage message, final Tag tag, final CallbackContext callbackContext, final boolean makeReadOnly) {
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
try {
Ndef ndef = Ndef.get(tag);
if (ndef != null) {
ndef.connect();
if (ndef.isWritable()) {
int size = message.toByteArray().length;
if (ndef.getMaxSize() < size) {
callbackContext.error("Tag capacity is " + ndef.getMaxSize() +
" bytes, message is " + size + " bytes.");
} else {
ndef.writeNdefMessage(message);
if(makeReadOnly) {
ndef.makeReadOnly(); // canMakeReadOnly() returns false for I-CODE tags even though makeReadOnly works fine
}
callbackContext.success();
}
} else {
callbackContext.error("Tag is read only");
}
ndef.close();
} else {
NdefFormatable formatable = NdefFormatable.get(tag);
if (formatable != null) {
formatable.connect();
if(makeReadOnly) {
formatable.formatReadOnly(message);
} else {
formatable.format(message);
}
callbackContext.success();
formatable.close();
} else {
callbackContext.error("Tag doesn't support NDEF");
}
}
} catch (FormatException e) {
callbackContext.error(e.getMessage());
} catch (TagLostException e) {
callbackContext.error(e.getMessage());
} catch (IOException e) {
callbackContext.error(e.getMessage());
}
}
});
}
phonegap-nfc.js
write: function (ndefMessage, win, fail, makeReadOnly) {
cordova.exec(win, fail, "NfcPlugin", "writeTag", [ndefMessage, makeReadOnly]);
},
from phonegap-nfc.
My application i is attendance system i want to nfc tag read -write protected for me and read proteted for other
how it implement tell me
from phonegap-nfc.
@ashish447 this isn't available right now, you can attempt to add it yourself by editing the Nfcplugin.java file with the code above but if I was you I'd wait for @don to implement it. Alternatively you can make the chagnes to teh NfcPlugin.java file and open a pull request with your changes in.
from phonegap-nfc.
JohnMcLear thanks .u know about Rfid card tag i have nexsus 7 device but it can't read Rfid Card
what specification of rfid tag
from phonegap-nfc.
Hi,
Is there any time line for this to be added in? Would be very useful for a project we are looking to start.
Cheers
Mark
from phonegap-nfc.
what You want to say ?
On Wed, Dec 4, 2013 at 8:08 PM, mcotter [email protected] wrote:
Hi,
Is there any time line for this to be added in? Would be very useful for a
project we are looking to start.Cheers
Mark—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-29809347
.
from phonegap-nfc.
You are hiring Project
On Wed, Dec 4, 2013 at 10:07 PM, Ashish Kasodariya <
[email protected]> wrote:
what You want to say ?
On Wed, Dec 4, 2013 at 8:08 PM, mcotter [email protected] wrote:
Hi,
Is there any time line for this to be added in? Would be very useful for
a project we are looking to start.Cheers
Mark—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-29809347
.
from phonegap-nfc.
@ashish447 Just wondering if the functionality is going to be added into the plugin?
from phonegap-nfc.
I'll try to get this in the next round of fixes.
from phonegap-nfc.
@don that would be great. If there is anything I can do to help let me know and I will do my best. cheers
from phonegap-nfc.
http://developer.android.com/reference/android/nfc/tech/Ndef.html#makeReadOnly()
from phonegap-nfc.
@don, i am working on a project where i have to write the data to the tag and then if someone tries to read the tag, user has to provide the pin. Reading and writing the tag is not an issue, issue is if someone want to read the tag after first time write, pin should be required. Do you have any suggestions how i can achieve this.
from phonegap-nfc.
@don, i also tried to encrypt the payload using my unique AES key and decrypt using the same key to protect my payload.
from phonegap-nfc.
hi don, do we have an API to set password to protect the NFC tag, such as the function which is python version http://nfcpy.org/latest/modules/tag.html#nfc.tag.Tag.protect ?
from phonegap-nfc.
Related Issues (20)
- 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
- Android Api 34 error Android 14 HOT 11
- NfcPlugin.java:554
- NEW Repo for issues and contributions HOT 9
- Read sectors and blocks of my mifare card with C#
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.