@capgo/capacitor-nfc 7.0.10 → 7.2.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/README.md CHANGED
@@ -10,6 +10,11 @@ Native NFC tag detection, reading, and writing for Capacitor apps on iOS and And
10
10
 
11
11
  Modern Capacitor port of the battle-tested [phonegap-nfc](https://github.com/chariotsolutions/phonegap-nfc) plugin, aligned with Capgo conventions and tooling.
12
12
 
13
+ ## Supported Tag Types
14
+
15
+ - **Standard NFC Forum Tags** (Type 1-4)
16
+ - **MIFARE Ultralight** - Full support for reading NDEF data from MIFARE Ultralight tags, including EV1 and NTAG variants. The plugin automatically detects MIFARE Ultralight cards and extracts NDEF messages in addition to standard NFC tags.
17
+
13
18
  ## Documentation
14
19
 
15
20
  The most complete documentation will live on the Capgo docs portal. Until then, explore the TypeScript definitions (`src/definitions.ts`) and run the included example app for a tour of the API.
@@ -337,15 +342,19 @@ Generic NFC discovery event dispatched by the plugin.
337
342
 
338
343
  Representation of the full tag information returned by the native layers.
339
344
 
340
- | Prop | Type | Description |
341
- | --------------------- | --------------------------------- | --------------------------------------------------------------------- |
342
- | **`id`** | <code>number[]</code> | Raw identifier bytes for the tag. |
343
- | **`techTypes`** | <code>string[]</code> | List of Android tech strings (e.g. `android.nfc.tech.Ndef`). |
344
- | **`type`** | <code>string \| null</code> | Human readable tag type when available (e.g. `NFC Forum Type 2`). |
345
- | **`maxSize`** | <code>number \| null</code> | Maximum writable size in bytes for tags that expose NDEF information. |
346
- | **`isWritable`** | <code>boolean \| null</code> | Indicates whether the tag can be written to. |
347
- | **`canMakeReadOnly`** | <code>boolean \| null</code> | Indicates whether the tag can be permanently locked. |
348
- | **`ndefMessage`** | <code>NdefRecord[] \| null</code> | Array of NDEF records discovered on the tag. |
345
+ Supports standard NFC Forum tags as well as MIFARE Ultralight cards (including
346
+ EV1 and NTAG variants). NDEF data is automatically extracted from MIFARE Ultralight
347
+ tags when available.
348
+
349
+ | Prop | Type | Description |
350
+ | --------------------- | --------------------------------- | -------------------------------------------------------------------------------------- |
351
+ | **`id`** | <code>number[]</code> | Raw identifier bytes for the tag. |
352
+ | **`techTypes`** | <code>string[]</code> | List of Android tech strings (e.g. `android.nfc.tech.Ndef`). |
353
+ | **`type`** | <code>string \| null</code> | Human readable tag type when available (e.g. `NFC Forum Type 2`, `MIFARE Ultralight`). |
354
+ | **`maxSize`** | <code>number \| null</code> | Maximum writable size in bytes for tags that expose NDEF information. |
355
+ | **`isWritable`** | <code>boolean \| null</code> | Indicates whether the tag can be written to. |
356
+ | **`canMakeReadOnly`** | <code>boolean \| null</code> | Indicates whether the tag can be permanently locked. |
357
+ | **`ndefMessage`** | <code>NdefRecord[] \| null</code> | Array of NDEF records discovered on the tag. |
349
358
 
350
359
 
351
360
  #### NfcStateChangeEvent
@@ -10,8 +10,10 @@ import android.nfc.NdefMessage;
10
10
  import android.nfc.NdefRecord;
11
11
  import android.nfc.NfcAdapter;
12
12
  import android.nfc.Tag;
13
+ import android.nfc.tech.MifareUltralight;
13
14
  import android.nfc.tech.Ndef;
14
15
  import android.nfc.tech.NdefFormatable;
16
+ import android.nfc.tech.NfcA;
15
17
  import android.os.Build;
16
18
  import android.os.Bundle;
17
19
  import android.provider.Settings;
@@ -356,21 +358,214 @@ public class CapacitorNfcPlugin extends Plugin {
356
358
  return;
357
359
  }
358
360
 
359
- Ndef ndef = Ndef.get(tag);
360
- NdefMessage cachedMessage = null;
361
- if (ndef != null) {
362
- try {
363
- cachedMessage = ndef.getCachedNdefMessage();
364
- } catch (Exception ex) {
365
- Log.w(TAG, "Unable to fetch cached NDEF message", ex);
361
+ NdefMessage message = null;
362
+ String[] techList = tag.getTechList();
363
+
364
+ // Check tech list first - if MIFARE Ultralight is present, prioritize it
365
+ // (tags can become stale very quickly, so we need to read immediately)
366
+ boolean hasMifareUltralight = Arrays.asList(techList).contains("android.nfc.tech.MifareUltralight");
367
+
368
+ if (hasMifareUltralight) {
369
+ // Try MIFARE Ultralight first - read immediately before tag becomes stale
370
+ MifareUltralight mifare = MifareUltralight.get(tag);
371
+ if (mifare != null) {
372
+ message = readNdefFromMifareUltralight(mifare);
373
+ }
374
+ }
375
+
376
+ // If no message from MIFARE, try standard NDEF
377
+ if (message == null) {
378
+ Ndef ndef = Ndef.get(tag);
379
+ if (ndef != null) {
380
+ // First try to get cached message (fast path)
381
+ try {
382
+ message = ndef.getCachedNdefMessage();
383
+ } catch (Exception ex) {
384
+ // Ignore - will try to read directly
385
+ }
386
+
387
+ // If no cached message, read it synchronously while tag is in range
388
+ if (message == null) {
389
+ try {
390
+ ndef.connect();
391
+ message = ndef.getNdefMessage();
392
+ ndef.close();
393
+ } catch (IOException | FormatException ex) {
394
+ try {
395
+ ndef.close();
396
+ } catch (IOException closeEx) {
397
+ // Ignore close errors
398
+ }
399
+ }
400
+ }
366
401
  }
367
402
  }
368
403
 
369
404
  lastTag.set(tag);
370
- lastMessage.set(cachedMessage);
405
+ lastMessage.set(message);
406
+ emitTagEvent(tag, message);
407
+ }
408
+
409
+ /**
410
+ * Reads NDEF message from MIFARE Ultralight tag by reading raw pages.
411
+ *
412
+ * Based on NFC Forum Type 2 Tag Operation specification:
413
+ * - NDEF data is stored in TLV (Type-Length-Value) format starting at page 4
414
+ * - TLV Type 0x03 indicates NDEF message
415
+ * - Length encoding: single byte if < 0xFF, or 0xFF + 2-byte length if >= 0xFF
416
+ *
417
+ * References:
418
+ * - Android MifareUltralight API: https://developer.android.com/reference/android/nfc/tech/MifareUltralight
419
+ * - NFC Forum Type 2 Tag Operation specification
420
+ */
421
+ private NdefMessage readNdefFromMifareUltralight(MifareUltralight mifare) {
422
+ try {
423
+ // Connect immediately - tag can become stale quickly
424
+ mifare.connect();
425
+
426
+ // Log tag variant for debugging
427
+ int tagType = mifare.getType();
428
+ String variantName;
429
+ switch (tagType) {
430
+ case MifareUltralight.TYPE_ULTRALIGHT:
431
+ variantName = "MIFARE Ultralight (standard, 64 bytes)";
432
+ break;
433
+ case MifareUltralight.TYPE_ULTRALIGHT_C:
434
+ variantName = "MIFARE Ultralight C (up to 192 bytes)";
435
+ break;
436
+ default:
437
+ variantName = "MIFARE Ultralight (type: " + tagType + ", unknown variant)";
438
+ break;
439
+ }
440
+ Log.d(TAG, "MIFARE Ultralight tag variant: " + variantName);
441
+
442
+ // Read pages 4-7 first (readPages reads 4 pages = 16 bytes at a time)
443
+ // This contains the TLV header
444
+ byte[] firstPages = mifare.readPages(4);
445
+ if (firstPages == null || firstPages.length < 4) {
446
+ mifare.close();
447
+ return null;
448
+ }
449
+
450
+ // Check for NDEF TLV (Type = 0x03 per NFC Forum spec)
451
+ if (firstPages[0] != 0x03) {
452
+ mifare.close();
453
+ return null;
454
+ }
455
+
456
+ // Parse TLV length field
457
+ int ndefLength;
458
+ int tlvHeaderSize;
459
+ if ((firstPages[1] & 0xFF) < 0xFF) {
460
+ // Short format: single byte length
461
+ ndefLength = firstPages[1] & 0xFF;
462
+ tlvHeaderSize = 2; // Type (1 byte) + Length (1 byte)
463
+ } else {
464
+ // Extended format: 0xFF + 2-byte length
465
+ if (firstPages.length < 4) {
466
+ mifare.close();
467
+ return null;
468
+ }
469
+ ndefLength = ((firstPages[2] & 0xFF) << 8) | (firstPages[3] & 0xFF);
470
+ tlvHeaderSize = 4; // Type (1 byte) + 0xFF (1 byte) + Length (2 bytes)
471
+ }
472
+
473
+ if (ndefLength == 0 || ndefLength > 1024) {
474
+ // Reasonable upper limit
475
+ mifare.close();
476
+ return null;
477
+ }
478
+
479
+ // Calculate total bytes needed (TLV header + NDEF data)
480
+ int totalBytesNeeded = tlvHeaderSize + ndefLength;
481
+ int totalPagesNeeded = (totalBytesNeeded + 3) / 4; // Round up to pages
482
+
483
+ // Read all necessary pages sequentially
484
+ // Standard MIFARE Ultralight: pages 4-15 (48 bytes)
485
+ // MIFARE Ultralight EV1: up to 256 pages (1024 bytes)
486
+ // MIFARE Ultralight C: up to 256 pages (1024 bytes)
487
+ byte[] allData = new byte[totalPagesNeeded * 4];
488
+ int bytesRead = 0;
489
+ int currentPage = 4;
490
+
491
+ // Copy first 16 bytes we already read
492
+ int bytesToCopy = Math.min(firstPages.length, allData.length);
493
+ System.arraycopy(firstPages, 0, allData, 0, bytesToCopy);
494
+ bytesRead = bytesToCopy;
495
+ currentPage += 4; // Move to page 8
496
+
497
+ // Read remaining pages if needed
498
+ // Support up to page 256 (MIFARE Ultralight EV1/C maximum)
499
+ while (bytesRead < totalBytesNeeded && currentPage < 260) {
500
+ try {
501
+ byte[] pages = mifare.readPages(currentPage);
502
+ if (pages == null || pages.length == 0) {
503
+ // No more pages available - tag might not support this many pages
504
+ break;
505
+ }
506
+
507
+ int bytesNeeded = totalBytesNeeded - bytesRead;
508
+ int bytesToRead = Math.min(pages.length, bytesNeeded);
509
+ System.arraycopy(pages, 0, allData, bytesRead, bytesToRead);
510
+ bytesRead += bytesToRead;
511
+ currentPage += 4; // readPages reads 4 pages at a time
512
+ } catch (IOException e) {
513
+ // Tag might not support reading beyond this page
514
+ // This is normal for tags with fewer pages than needed
515
+ break;
516
+ }
517
+ }
518
+
519
+ mifare.close();
520
+
521
+ // Check if we have enough data
522
+ if (bytesRead < totalBytesNeeded) {
523
+ // Incomplete read - tag might not have enough pages or was removed
524
+ Log.w(
525
+ TAG,
526
+ String.format(
527
+ "Incomplete NDEF read: read %d bytes, needed %d bytes (stopped at page %d, variant: %s)",
528
+ bytesRead,
529
+ totalBytesNeeded,
530
+ currentPage,
531
+ variantName
532
+ )
533
+ );
534
+ return null;
535
+ }
536
+
537
+ // Extract NDEF data (skip TLV header)
538
+ byte[] ndefData = new byte[ndefLength];
539
+ System.arraycopy(allData, tlvHeaderSize, ndefData, 0, ndefLength);
540
+
541
+ // Parse NDEF message
542
+ try {
543
+ return new NdefMessage(ndefData);
544
+ } catch (FormatException e) {
545
+ Log.w(TAG, "Failed to parse NDEF message from MIFARE Ultralight", e);
546
+ return null;
547
+ }
548
+ } catch (SecurityException e) {
549
+ // Tag became stale - this happens if tag is removed or too much time passed
550
+ try {
551
+ mifare.close();
552
+ } catch (Exception closeEx) {
553
+ // Ignore close errors
554
+ }
555
+ return null;
556
+ } catch (IOException e) {
557
+ try {
558
+ mifare.close();
559
+ } catch (IOException closeEx) {
560
+ // Ignore close errors
561
+ }
562
+ return null;
563
+ }
564
+ }
371
565
 
372
- JSObject tagJson = NfcJsonConverter.tagToJSObject(tag, cachedMessage);
373
- String eventType = determineEventType(tag, cachedMessage);
566
+ private void emitTagEvent(Tag tag, NdefMessage message) {
567
+ JSObject tagJson = NfcJsonConverter.tagToJSObject(tag, message);
568
+ String eventType = determineEventType(tag, message);
374
569
  JSObject event = new JSObject();
375
570
  event.put("type", eventType);
376
571
  event.put("tag", tagJson);
package/dist/docs.json CHANGED
@@ -363,7 +363,7 @@
363
363
  {
364
364
  "name": "NfcTag",
365
365
  "slug": "nfctag",
366
- "docs": "Representation of the full tag information returned by the native layers.",
366
+ "docs": "Representation of the full tag information returned by the native layers.\n\nSupports standard NFC Forum tags as well as MIFARE Ultralight cards (including\nEV1 and NTAG variants). NDEF data is automatically extracted from MIFARE Ultralight\ntags when available.",
367
367
  "tags": [],
368
368
  "methods": [],
369
369
  "properties": [
@@ -384,7 +384,7 @@
384
384
  {
385
385
  "name": "type",
386
386
  "tags": [],
387
- "docs": "Human readable tag type when available (e.g. `NFC Forum Type 2`).",
387
+ "docs": "Human readable tag type when available (e.g. `NFC Forum Type 2`, `MIFARE Ultralight`).",
388
388
  "complexTypes": [],
389
389
  "type": "string | null | undefined"
390
390
  },
@@ -42,6 +42,10 @@ export interface NdefRecord {
42
42
  }
43
43
  /**
44
44
  * Representation of the full tag information returned by the native layers.
45
+ *
46
+ * Supports standard NFC Forum tags as well as MIFARE Ultralight cards (including
47
+ * EV1 and NTAG variants). NDEF data is automatically extracted from MIFARE Ultralight
48
+ * tags when available.
45
49
  */
46
50
  export interface NfcTag {
47
51
  /**
@@ -53,7 +57,7 @@ export interface NfcTag {
53
57
  */
54
58
  techTypes?: string[];
55
59
  /**
56
- * Human readable tag type when available (e.g. `NFC Forum Type 2`).
60
+ * Human readable tag type when available (e.g. `NFC Forum Type 2`, `MIFARE Ultralight`).
57
61
  */
58
62
  type?: string | null;
59
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Possible NFC adapter states returned by {@link CapacitorNfcPlugin.getStatus}.\n *\n * Matches the constants provided by the original PhoneGap NFC plugin for\n * compatibility with existing applications.\n */\nexport type NfcStatus = 'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED';\n\n/**\n * Event type describing the kind of NFC discovery that happened.\n *\n * - `tag`: A generic NFC tag (no NDEF payload).\n * - `ndef`: A tag exposing an NDEF payload.\n * - `ndef-mime`: An NDEF tag that matched one of the MIME type filters.\n * - `ndef-formatable`: A tag that can be formatted to NDEF.\n */\nexport type NfcEventType = 'tag' | 'ndef' | 'ndef-mime' | 'ndef-formatable';\n\n/**\n * JSON structure representing a single NDEF record.\n *\n * Mirrors the data format returned by the legacy Cordova implementation and\n * uses integer arrays instead of strings to preserve the original payload\n * bytes.\n */\nexport interface NdefRecord {\n /**\n * Type Name Format identifier.\n */\n tnf: number;\n /**\n * Type field expressed as an array of byte values.\n */\n type: number[];\n /**\n * Record identifier expressed as an array of byte values.\n */\n id: number[];\n /**\n * Raw payload expressed as an array of byte values.\n */\n payload: number[];\n}\n\n/**\n * Representation of the full tag information returned by the native layers.\n */\nexport interface NfcTag {\n /**\n * Raw identifier bytes for the tag.\n */\n id?: number[];\n /**\n * List of Android tech strings (e.g. `android.nfc.tech.Ndef`).\n */\n techTypes?: string[];\n /**\n * Human readable tag type when available (e.g. `NFC Forum Type 2`).\n */\n type?: string | null;\n /**\n * Maximum writable size in bytes for tags that expose NDEF information.\n */\n maxSize?: number | null;\n /**\n * Indicates whether the tag can be written to.\n */\n isWritable?: boolean | null;\n /**\n * Indicates whether the tag can be permanently locked.\n */\n canMakeReadOnly?: boolean | null;\n /**\n * Array of NDEF records discovered on the tag.\n */\n ndefMessage?: NdefRecord[] | null;\n}\n\n/**\n * Generic NFC discovery event dispatched by the plugin.\n */\nexport interface NfcEvent {\n type: NfcEventType;\n tag: NfcTag;\n}\n\n/**\n * Options controlling the behaviour of {@link CapacitorNfcPlugin.startScanning}.\n */\nexport interface StartScanningOptions {\n /**\n * iOS-only: closes the NFC session automatically after the first successful tag read.\n * Defaults to `true`.\n */\n invalidateAfterFirstRead?: boolean;\n /**\n * iOS-only: custom message displayed in the NFC system sheet while scanning.\n */\n alertMessage?: string;\n /**\n * Android-only: raw flags passed to `NfcAdapter.enableReaderMode`.\n * Defaults to enabling all tag types with skipping NDEF checks.\n */\n androidReaderModeFlags?: number;\n}\n\n/**\n * Options used when writing an NDEF message on the current tag.\n */\nexport interface WriteTagOptions {\n /**\n * Array of records that compose the NDEF message to be written.\n */\n records: NdefRecord[];\n /**\n * When `true`, the plugin attempts to format NDEF-formattable tags before writing.\n * Defaults to `true`.\n */\n allowFormat?: boolean;\n}\n\n/**\n * Options used when sharing an NDEF message with another device using Android Beam / P2P mode.\n */\nexport interface ShareTagOptions {\n records: NdefRecord[];\n}\n\n/**\n * Event emitted whenever the NFC adapter availability changes.\n */\nexport interface NfcStateChangeEvent {\n status: NfcStatus;\n enabled: boolean;\n}\n\n/**\n * Public API surface for the Capacitor NFC plugin.\n *\n * The interface intentionally mirrors the behaviour of the reference PhoneGap\n * implementation to ease migration while embracing idiomatic Capacitor APIs.\n */\nexport interface CapacitorNfcPlugin {\n /**\n * Starts listening for NFC tags.\n */\n startScanning(options?: StartScanningOptions): Promise<void>;\n /**\n * Stops the ongoing NFC scanning session.\n */\n stopScanning(): Promise<void>;\n /**\n * Writes the provided NDEF records to the last discovered tag.\n */\n write(options: WriteTagOptions): Promise<void>;\n /**\n * Attempts to erase the last discovered tag by writing an empty NDEF message.\n */\n erase(): Promise<void>;\n /**\n * Attempts to make the last discovered tag read-only.\n */\n makeReadOnly(): Promise<void>;\n /**\n * Shares an NDEF message with another device via peer-to-peer (Android only).\n */\n share(options: ShareTagOptions): Promise<void>;\n /**\n * Stops sharing previously provided NDEF message (Android only).\n */\n unshare(): Promise<void>;\n /**\n * Returns the current NFC adapter status.\n */\n getStatus(): Promise<{ status: NfcStatus }>;\n /**\n * Opens the system settings page where the user can enable NFC.\n */\n showSettings(): Promise<void>;\n /**\n * Returns the version string baked into the native plugin.\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n addListener(eventName: 'nfcEvent', listenerFunc: (event: NfcEvent) => void): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'tagDiscovered' | 'ndefDiscovered' | 'ndefMimeDiscovered' | 'ndefFormatableDiscovered',\n listenerFunc: (event: NfcEvent) => void,\n ): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'nfcStateChange',\n listenerFunc: (event: NfcStateChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n}\n\nexport type { PluginListenerHandle } from '@capacitor/core';\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Possible NFC adapter states returned by {@link CapacitorNfcPlugin.getStatus}.\n *\n * Matches the constants provided by the original PhoneGap NFC plugin for\n * compatibility with existing applications.\n */\nexport type NfcStatus = 'NFC_OK' | 'NO_NFC' | 'NFC_DISABLED' | 'NDEF_PUSH_DISABLED';\n\n/**\n * Event type describing the kind of NFC discovery that happened.\n *\n * - `tag`: A generic NFC tag (no NDEF payload).\n * - `ndef`: A tag exposing an NDEF payload.\n * - `ndef-mime`: An NDEF tag that matched one of the MIME type filters.\n * - `ndef-formatable`: A tag that can be formatted to NDEF.\n */\nexport type NfcEventType = 'tag' | 'ndef' | 'ndef-mime' | 'ndef-formatable';\n\n/**\n * JSON structure representing a single NDEF record.\n *\n * Mirrors the data format returned by the legacy Cordova implementation and\n * uses integer arrays instead of strings to preserve the original payload\n * bytes.\n */\nexport interface NdefRecord {\n /**\n * Type Name Format identifier.\n */\n tnf: number;\n /**\n * Type field expressed as an array of byte values.\n */\n type: number[];\n /**\n * Record identifier expressed as an array of byte values.\n */\n id: number[];\n /**\n * Raw payload expressed as an array of byte values.\n */\n payload: number[];\n}\n\n/**\n * Representation of the full tag information returned by the native layers.\n *\n * Supports standard NFC Forum tags as well as MIFARE Ultralight cards (including\n * EV1 and NTAG variants). NDEF data is automatically extracted from MIFARE Ultralight\n * tags when available.\n */\nexport interface NfcTag {\n /**\n * Raw identifier bytes for the tag.\n */\n id?: number[];\n /**\n * List of Android tech strings (e.g. `android.nfc.tech.Ndef`).\n */\n techTypes?: string[];\n /**\n * Human readable tag type when available (e.g. `NFC Forum Type 2`, `MIFARE Ultralight`).\n */\n type?: string | null;\n /**\n * Maximum writable size in bytes for tags that expose NDEF information.\n */\n maxSize?: number | null;\n /**\n * Indicates whether the tag can be written to.\n */\n isWritable?: boolean | null;\n /**\n * Indicates whether the tag can be permanently locked.\n */\n canMakeReadOnly?: boolean | null;\n /**\n * Array of NDEF records discovered on the tag.\n */\n ndefMessage?: NdefRecord[] | null;\n}\n\n/**\n * Generic NFC discovery event dispatched by the plugin.\n */\nexport interface NfcEvent {\n type: NfcEventType;\n tag: NfcTag;\n}\n\n/**\n * Options controlling the behaviour of {@link CapacitorNfcPlugin.startScanning}.\n */\nexport interface StartScanningOptions {\n /**\n * iOS-only: closes the NFC session automatically after the first successful tag read.\n * Defaults to `true`.\n */\n invalidateAfterFirstRead?: boolean;\n /**\n * iOS-only: custom message displayed in the NFC system sheet while scanning.\n */\n alertMessage?: string;\n /**\n * Android-only: raw flags passed to `NfcAdapter.enableReaderMode`.\n * Defaults to enabling all tag types with skipping NDEF checks.\n */\n androidReaderModeFlags?: number;\n}\n\n/**\n * Options used when writing an NDEF message on the current tag.\n */\nexport interface WriteTagOptions {\n /**\n * Array of records that compose the NDEF message to be written.\n */\n records: NdefRecord[];\n /**\n * When `true`, the plugin attempts to format NDEF-formattable tags before writing.\n * Defaults to `true`.\n */\n allowFormat?: boolean;\n}\n\n/**\n * Options used when sharing an NDEF message with another device using Android Beam / P2P mode.\n */\nexport interface ShareTagOptions {\n records: NdefRecord[];\n}\n\n/**\n * Event emitted whenever the NFC adapter availability changes.\n */\nexport interface NfcStateChangeEvent {\n status: NfcStatus;\n enabled: boolean;\n}\n\n/**\n * Public API surface for the Capacitor NFC plugin.\n *\n * The interface intentionally mirrors the behaviour of the reference PhoneGap\n * implementation to ease migration while embracing idiomatic Capacitor APIs.\n */\nexport interface CapacitorNfcPlugin {\n /**\n * Starts listening for NFC tags.\n */\n startScanning(options?: StartScanningOptions): Promise<void>;\n /**\n * Stops the ongoing NFC scanning session.\n */\n stopScanning(): Promise<void>;\n /**\n * Writes the provided NDEF records to the last discovered tag.\n */\n write(options: WriteTagOptions): Promise<void>;\n /**\n * Attempts to erase the last discovered tag by writing an empty NDEF message.\n */\n erase(): Promise<void>;\n /**\n * Attempts to make the last discovered tag read-only.\n */\n makeReadOnly(): Promise<void>;\n /**\n * Shares an NDEF message with another device via peer-to-peer (Android only).\n */\n share(options: ShareTagOptions): Promise<void>;\n /**\n * Stops sharing previously provided NDEF message (Android only).\n */\n unshare(): Promise<void>;\n /**\n * Returns the current NFC adapter status.\n */\n getStatus(): Promise<{ status: NfcStatus }>;\n /**\n * Opens the system settings page where the user can enable NFC.\n */\n showSettings(): Promise<void>;\n /**\n * Returns the version string baked into the native plugin.\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n addListener(eventName: 'nfcEvent', listenerFunc: (event: NfcEvent) => void): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'tagDiscovered' | 'ndefDiscovered' | 'ndefMimeDiscovered' | 'ndefFormatableDiscovered',\n listenerFunc: (event: NfcEvent) => void,\n ): Promise<PluginListenerHandle>;\n addListener(\n eventName: 'nfcStateChange',\n listenerFunc: (event: NfcStateChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n}\n\nexport type { PluginListenerHandle } from '@capacitor/core';\n"]}
@@ -4,7 +4,7 @@ import UIKit
4
4
 
5
5
  @objc(NfcPlugin)
6
6
  public class NfcPlugin: CAPPlugin, CAPBridgedPlugin {
7
- private let pluginVersion: String = "7.0.10"
7
+ private let pluginVersion: String = "7.2.0"
8
8
 
9
9
  public let identifier = "NfcPlugin"
10
10
  public let jsName = "CapacitorNfc"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-nfc",
3
- "version": "7.0.10",
3
+ "version": "7.2.0",
4
4
  "description": "Native NFC tag discovery, reading and writing for Capacitor apps on iOS and Android.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",