community-cordova-plugin-nfc 1.5.4 → 1.6.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,6 +1,6 @@
1
1
  {
2
2
  "name": "community-cordova-plugin-nfc",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Community Cordova NFC Plugin - Read and write NDEF messages, advanced tag analysis, raw memory access",
5
5
  "main": "./types/index.d.ts",
6
6
  "types": "./types/index.d.ts",
package/plugin.xml CHANGED
@@ -7,7 +7,7 @@
7
7
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
8
8
  xmlns:android="http://schemas.android.com/apk/res/android"
9
9
  id="community-cordova-plugin-nfc"
10
- version="1.5.4">
10
+ version="1.6.0">
11
11
 
12
12
  <name>NFC</name>
13
13
  <description>Community Cordova NFC Plugin - Read and write NDEF messages, advanced tag analysis, raw memory access</description>
@@ -18,7 +18,7 @@
18
18
 
19
19
  <platform name="android">
20
20
  <js-module src="www/phonegap-nfc.js" name="NFC">
21
- <runs />
21
+ <clobbers target="NfcPlugin" />
22
22
  </js-module>
23
23
 
24
24
  <config-file target="res/xml/config.xml" parent="/*">
@@ -42,7 +42,7 @@
42
42
 
43
43
  <platform name="wp8">
44
44
  <js-module src="www/phonegap-nfc.js" name="NFC">
45
- <runs />
45
+ <clobbers target="NfcPlugin" />
46
46
  </js-module>
47
47
 
48
48
  <config-file target="config.xml" parent="/*">
@@ -63,7 +63,7 @@
63
63
  <!-- windows -->
64
64
  <platform name="windows">
65
65
  <js-module src="www/phonegap-nfc.js" name="NFC">
66
- <runs />
66
+ <clobbers target="NfcPlugin" />
67
67
  </js-module>
68
68
 
69
69
  <config-file target="config.xml" parent="/*">
@@ -92,7 +92,7 @@
92
92
 
93
93
  <platform name="blackberry10">
94
94
  <js-module src="www/phonegap-nfc.js" name="NFC">
95
- <runs />
95
+ <clobbers target="NfcPlugin" />
96
96
  </js-module>
97
97
  <!-- override defaults for BB10 -->
98
98
  <js-module src="www/phonegap-nfc-blackberry.js" name="NFCBB10">
@@ -110,7 +110,7 @@
110
110
 
111
111
  <platform name="ios">
112
112
  <js-module src="www/phonegap-nfc.js" name="NFC">
113
- <runs />
113
+ <clobbers target="NfcPlugin" />
114
114
  </js-module>
115
115
 
116
116
  <config-file parent="/*" target="config.xml">
@@ -120,16 +120,15 @@
120
120
  </config-file>
121
121
 
122
122
  <!-- https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_nfc_readersession_formats?language=objc -->
123
+ <!-- Note: NDEF is deprecated/disallowed in iOS SDK 26.1+ (iOS 18+). Use TAG only. -->
123
124
  <config-file parent="com.apple.developer.nfc.readersession.formats" platform="ios" target="*-Debug.plist">
124
125
  <array>
125
- <string>NDEF</string>
126
- <string>TAG</string>
126
+ <string>TAG</string>
127
127
  </array>
128
128
  </config-file>
129
129
  <config-file parent="com.apple.developer.nfc.readersession.formats" platform="ios" target="*-Release.plist">
130
130
  <array>
131
- <string>NDEF</string>
132
- <string>TAG</string>
131
+ <string>TAG</string>
133
132
  </array>
134
133
  </config-file>
135
134
 
package/types/index.d.ts CHANGED
@@ -206,6 +206,28 @@ export interface INfcPlugin {
206
206
  onError?: (error: string) => void
207
207
  ): void;
208
208
 
209
+ /**
210
+ * Register for tag discovered events (non-NDEF tags and NDEF tags)
211
+ * @param callback - Called when tag is detected
212
+ * @param onSuccess - Called on successful registration
213
+ * @param onError - Called on error
214
+ */
215
+ addTagDiscoveredListener(
216
+ callback: (event: INfcEvent) => void,
217
+ onSuccess?: () => void,
218
+ onError?: (error: string) => void
219
+ ): void;
220
+
221
+ /**
222
+ * Remove tag discovered listener
223
+ * @param onSuccess - Called on success
224
+ * @param onError - Called on error
225
+ */
226
+ removeTagDiscoveredListener(
227
+ onSuccess?: () => void,
228
+ onError?: (error: string) => void
229
+ ): void;
230
+
209
231
  // ========== NFC Status ==========
210
232
 
211
233
  /**
@@ -292,6 +314,16 @@ export interface INfcPlugin {
292
314
  // ============================================
293
315
 
294
316
  export interface INdefUtil {
317
+ /**
318
+ * Create a generic NDEF record
319
+ * @param tnf - Type Name Format (0-7)
320
+ * @param type - Record type as byte array or string
321
+ * @param id - Record ID as byte array or string
322
+ * @param payload - Payload as byte array or string
323
+ * @returns NDEF record
324
+ */
325
+ record(tnf: number, type: number[] | string, id: number[] | string, payload: number[] | string): INdefRecord;
326
+
295
327
  /**
296
328
  * Create a text record
297
329
  * @param text - Text content
@@ -407,23 +439,30 @@ export interface ITnf {
407
439
  TNF_RESERVED: 7;
408
440
  }
409
441
 
442
+ // ============================================
443
+ // Combined Plugin Interface (following SecurityPlugin pattern)
444
+ // ============================================
445
+
446
+ export interface NfcManager extends INfcPlugin {
447
+ /** NDEF helper utilities */
448
+ NdefPlugin: INdefUtil;
449
+ /** General utilities */
450
+ NfcUtil: IUtil;
451
+ /** Fire NFC tag event */
452
+ fireNfcTagEvent: (eventType: string, tagAsJson: string) => void;
453
+ }
454
+
410
455
  // ============================================
411
456
  // Global Declarations
412
457
  // ============================================
413
458
 
414
459
  declare global {
415
460
  interface Window {
416
- nfc: INfcPlugin;
417
- ndef: INdefUtil;
418
- util: IUtil;
461
+ NfcPlugin: NfcManager;
419
462
  }
420
463
 
421
- /** NFC Plugin instance */
422
- var nfc: INfcPlugin;
423
- /** NDEF helper utilities */
424
- var ndef: INdefUtil;
425
- /** General utilities */
426
- var util: IUtil;
464
+ /** NFC Plugin instance (following SecurityPlugin pattern) */
465
+ var NfcPlugin: NfcManager;
427
466
  }
428
467
 
429
- export default INfcPlugin;
468
+ export default NfcManager;
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Community Cordova NFC Plugin - NfcPlugin wrapper
3
+ * Licensed under MIT License
4
+ */
5
+
6
+ // Import from main phonegap-nfc.js (which sets window.nfc)
7
+ var nfc = require('./phonegap-nfc').nfc;
8
+
9
+ module.exports = nfc;
@@ -1123,19 +1123,12 @@ nfc.bytesToString = util.bytesToString;
1123
1123
  nfc.stringToBytes = util.stringToBytes;
1124
1124
  nfc.bytesToHexString = util.bytesToHexString;
1125
1125
 
1126
- // kludge some global variables for plugman js-module support
1127
- // eventually these should be replaced and referenced via the module
1128
- window.nfc = nfc;
1129
- window.ndef = ndef;
1130
- window.util = util;
1131
- window.fireNfcTagEvent = fireNfcTagEvent;
1132
-
1133
- // This channel receives nfcEvent data from native code
1126
+ // This channel receives nfcEvent data from native code
1134
1127
  // and fires JavaScript events.
1135
1128
  require('cordova/channel').onCordovaReady.subscribe(function() {
1136
1129
  require('cordova/exec')(success, null, 'NfcPlugin', 'channel', []);
1137
1130
  function success(message) {
1138
- if (!message.type) {
1131
+ if (!message.type) {
1139
1132
  console.log(message);
1140
1133
  } else {
1141
1134
  console.log("Received NFC data, firing '" + message.type + "' event");
@@ -1146,3 +1139,13 @@ require('cordova/channel').onCordovaReady.subscribe(function() {
1146
1139
  }
1147
1140
  }
1148
1141
  });
1142
+
1143
+ // Export using same convention as SecurityPlugin
1144
+ // NfcPlugin is the main export (clobbered via plugin.xml)
1145
+ // NdefPlugin and NfcUtil are properties on the export
1146
+ var NfcPluginExport = nfc;
1147
+ NfcPluginExport.NdefPlugin = ndef;
1148
+ NfcPluginExport.NfcUtil = util;
1149
+ NfcPluginExport.fireNfcTagEvent = fireNfcTagEvent;
1150
+
1151
+ module.exports = NfcPluginExport;