@capgo/capacitor-nfc 8.0.13 → 8.0.15
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/android/build.gradle
CHANGED
|
@@ -30,7 +30,7 @@ android {
|
|
|
30
30
|
buildTypes {
|
|
31
31
|
release {
|
|
32
32
|
minifyEnabled false
|
|
33
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
lintOptions {
|
|
@@ -4,7 +4,7 @@ import UIKit
|
|
|
4
4
|
|
|
5
5
|
@objc(NfcPlugin)
|
|
6
6
|
public class NfcPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
7
|
-
private let pluginVersion: String = "8.0.
|
|
7
|
+
private let pluginVersion: String = "8.0.15"
|
|
8
8
|
|
|
9
9
|
public let identifier = "NfcPlugin"
|
|
10
10
|
public let jsName = "CapacitorNfc"
|
|
@@ -536,14 +536,17 @@ extension NfcPlugin: NFCTagReaderSessionDelegate {
|
|
|
536
536
|
|
|
537
537
|
if error == nil && status != .notSupported {
|
|
538
538
|
// Tag supports NDEF, try to read it
|
|
539
|
-
tag.readNDEF { [weak self] message,
|
|
539
|
+
tag.readNDEF { [weak self] message, readError in
|
|
540
540
|
guard let self else {
|
|
541
541
|
return
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
+
// For blank/formatted tags that are writable but have no NDEF message yet,
|
|
545
|
+
// readNDEF may return nil message without an error, or return an error.
|
|
546
|
+
// We should emit the tag with its UID and writability info.
|
|
544
547
|
if message == nil {
|
|
545
|
-
// NDEF read failed
|
|
546
|
-
self.emitTagEvent(tag: tag, message: nil, session: session)
|
|
548
|
+
// Blank tag or NDEF read failed - emit tag with UID and status info
|
|
549
|
+
self.emitTagEvent(tag: tag, status: status, capacity: capacity, message: nil, session: session)
|
|
547
550
|
} else {
|
|
548
551
|
// Successfully read NDEF
|
|
549
552
|
self.currentTag = tag
|
|
@@ -556,12 +559,12 @@ extension NfcPlugin: NFCTagReaderSessionDelegate {
|
|
|
556
559
|
}
|
|
557
560
|
} else {
|
|
558
561
|
// Tag doesn't support NDEF or query failed - just emit UID
|
|
559
|
-
self.emitTagEvent(tag: tag, message: nil, session: session)
|
|
562
|
+
self.emitTagEvent(tag: tag, status: .notSupported, capacity: 0, message: nil, session: session)
|
|
560
563
|
}
|
|
561
564
|
}
|
|
562
565
|
}
|
|
563
566
|
|
|
564
|
-
private func emitTagEvent(tag: NFCNDEFTag, message: NFCNDEFMessage?, session: NFCTagReaderSession) {
|
|
567
|
+
private func emitTagEvent(tag: NFCNDEFTag, status: NFCNDEFStatus, capacity: Int, message: NFCNDEFMessage?, session: NFCTagReaderSession) {
|
|
565
568
|
// Save the current tag for writing
|
|
566
569
|
currentTag = tag
|
|
567
570
|
|
|
@@ -574,9 +577,14 @@ extension NfcPlugin: NFCTagReaderSessionDelegate {
|
|
|
574
577
|
|
|
575
578
|
tagInfo["techTypes"] = detectTechTypes(for: tag)
|
|
576
579
|
tagInfo["type"] = translateType(for: tag)
|
|
580
|
+
|
|
581
|
+
// Include writability and capacity information
|
|
582
|
+
if status != .notSupported {
|
|
583
|
+
tagInfo["isWritable"] = status == .readWrite
|
|
584
|
+
tagInfo["maxSize"] = capacity
|
|
585
|
+
}
|
|
577
586
|
|
|
578
587
|
if let message {
|
|
579
|
-
tagInfo["isWritable"] = true
|
|
580
588
|
tagInfo["ndefMessage"] = message.records.map { record in
|
|
581
589
|
[
|
|
582
590
|
"tnf": NSNumber(value: record.typeNameFormat.rawValue),
|
package/package.json
CHANGED