@iotize/device-com-nfc.cordova 3.7.1 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iotize/device-com-nfc.cordova",
|
|
3
3
|
"main": "bundles/iotize-device-com-nfc.cordova.umd.js",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.8.0",
|
|
5
5
|
"description": "Near Field Communication (NFC) Plugin. Read and write NDEF messages to NFC tags and share NDEF messages with peers.",
|
|
6
6
|
"cordova": {
|
|
7
7
|
"id": "@iotize/device-com-nfc.cordova",
|
|
@@ -6,12 +6,10 @@ import android.content.Context;
|
|
|
6
6
|
import android.content.Intent;
|
|
7
7
|
import android.content.IntentFilter;
|
|
8
8
|
import android.content.IntentFilter.MalformedMimeTypeException;
|
|
9
|
-
import android.net.Uri;
|
|
10
9
|
import android.nfc.FormatException;
|
|
11
10
|
import android.nfc.NdefMessage;
|
|
12
11
|
import android.nfc.NdefRecord;
|
|
13
12
|
import android.nfc.NfcAdapter;
|
|
14
|
-
import android.nfc.NfcEvent;
|
|
15
13
|
import android.nfc.Tag;
|
|
16
14
|
import android.nfc.TagLostException;
|
|
17
15
|
import android.nfc.tech.Ndef;
|
|
@@ -116,6 +114,7 @@ public class NfcPlugin extends CordovaPlugin {
|
|
|
116
114
|
private PendingIntent pendingIntent = null;
|
|
117
115
|
|
|
118
116
|
private Intent savedIntent = null;
|
|
117
|
+
private long savedIntentTime = 0;
|
|
119
118
|
|
|
120
119
|
private CallbackContext readerModeCallback;
|
|
121
120
|
@Nullable
|
|
@@ -340,6 +339,20 @@ public class NfcPlugin extends CordovaPlugin {
|
|
|
340
339
|
addTagFilter();
|
|
341
340
|
restartNfc();
|
|
342
341
|
callbackContext.success();
|
|
342
|
+
if (savedIntent != null) {
|
|
343
|
+
long tagOld = System.currentTimeMillis()-savedIntentTime;
|
|
344
|
+
if (tagOld < 3000) {
|
|
345
|
+
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(savedIntent.getAction())) {
|
|
346
|
+
Tag tag = savedIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
|
|
347
|
+
if (tag != null ) {
|
|
348
|
+
Log.i(TAG, "registerDefaultTag() fire recently tapped tag (" + tagOld + "ms ago)");
|
|
349
|
+
Parcelable[] messages = savedIntent.getParcelableArrayExtra((NfcAdapter.EXTRA_NDEF_MESSAGES));
|
|
350
|
+
fireTagEvent(tag, messages);
|
|
351
|
+
savedIntentTime = 0;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
343
356
|
}
|
|
344
357
|
|
|
345
358
|
private void removeDefaultTag(CallbackContext callbackContext) {
|
|
@@ -665,8 +678,8 @@ public class NfcPlugin extends CordovaPlugin {
|
|
|
665
678
|
if (action.equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) {
|
|
666
679
|
Ndef ndef = Ndef.get(tag);
|
|
667
680
|
fireNdefEvent(NDEF_MIME, ndef, messages);
|
|
668
|
-
Log.d(TAG, "Saving Intent for connect" + intent);
|
|
669
681
|
savedIntent = intent;
|
|
682
|
+
savedIntentTime = System.currentTimeMillis();
|
|
670
683
|
fireTagEvent(tag, messages);
|
|
671
684
|
|
|
672
685
|
} else if (action.equals(NfcAdapter.ACTION_TECH_DISCOVERED)) {
|