@iotize/device-com-nfc.cordova 3.9.0 → 3.9.2
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/bundles/iotize-device-com-nfc.cordova.umd.js +12 -33
- package/bundles/iotize-device-com-nfc.cordova.umd.js.map +1 -1
- package/bundles/iotize-device-com-nfc.cordova.umd.min.js +1 -1
- package/bundles/iotize-device-com-nfc.cordova.umd.min.js.map +1 -1
- package/esm2015/www/cordova-interface.js.map +1 -1
- package/esm2015/www/index.js.map +1 -1
- package/esm2015/www/ndef/parse-ndef-message.js.map +1 -1
- package/esm2015/www/nfc-com-protocol.js.map +1 -1
- package/fesm2015/iotize-device-com-nfc.cordova.js.map +1 -1
- package/package.json +2 -2
- package/plugin.xml +98 -98
- package/src/android/.gradle/4.10.1/fileHashes/fileHashes.bin +0 -0
- package/src/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
- package/src/android/.gradle/vcs-1/gc.properties +0 -0
- package/src/android/src/com/chariotsolutions/nfc/plugin/NfcPlugin.java +1162 -1151
- package/src/ios/AppDelegate+NFC.swift +51 -51
- package/src/ios/NFCHelpers.swift +144 -144
- package/src/ios/NFCNDEFDelegate.swift +78 -78
- package/src/ios/NFCTagReader.swift +536 -506
- package/src/ios/NFCTapPlugin.swift +57 -1
- package/www/phonegap-nfc.js +911 -911
|
@@ -176,7 +176,7 @@ import CoreNFC
|
|
|
176
176
|
DispatchQueue.main.async {
|
|
177
177
|
if error != nil {
|
|
178
178
|
self.lastError = error
|
|
179
|
-
self.sendError(command: command, result: "Tag was lost")
|
|
179
|
+
self.sendError(command: command, result: "Tag was lost")//error!.localizedDescription)
|
|
180
180
|
} else {
|
|
181
181
|
printNFC("responded \(response!.hexEncodedString())")
|
|
182
182
|
self.sendSuccess(command: command, result: response!.hexEncodedString())
|
|
@@ -412,6 +412,8 @@ import CoreNFC
|
|
|
412
412
|
alertMessage = alertMessageFromCommand
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
printNFC("Begin session for tech \(tech) with message: \(alertMessage)")
|
|
416
|
+
|
|
415
417
|
DispatchQueue.main.async {
|
|
416
418
|
printNFC("Begin session NFC \(String(describing: pollingOption))")
|
|
417
419
|
if self.nfcController == nil {
|
|
@@ -523,5 +525,59 @@ import CoreNFC
|
|
|
523
525
|
func registerChannel() {
|
|
524
526
|
isListeningNDEF = true // Flag for the AppDelegate
|
|
525
527
|
}
|
|
528
|
+
|
|
529
|
+
@objc(writeTag:)
|
|
530
|
+
func writeTag(command: CDVInvokedUrlCommand) {
|
|
531
|
+
printNFC("writeTag")
|
|
532
|
+
|
|
533
|
+
guard #available(iOS 13.0, *) else {
|
|
534
|
+
sendError(command: command, result: "write is only available on iOS 13+")
|
|
535
|
+
return
|
|
536
|
+
}
|
|
537
|
+
guard let messagesJSON = command.argument(at: 0) as? [NSDictionary] else {
|
|
538
|
+
sendError(command: command, result: "No message to write")
|
|
539
|
+
return
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
guard let tagReader = self.nfcController as? NFCTagReader else {
|
|
543
|
+
self.sendError(command: command, result: "no session available")
|
|
544
|
+
return
|
|
545
|
+
}
|
|
546
|
+
guard ((tagReader.comSession?.isReady) != nil) else {
|
|
547
|
+
self.sendError(command: command, result: "no session available")
|
|
548
|
+
return
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
printNFC("write NDEF messages with \(messagesJSON.count) records")
|
|
552
|
+
|
|
553
|
+
//convert message array to NFCNDEFMessage
|
|
554
|
+
var records: [NFCNDEFPayload] = []
|
|
555
|
+
for record in messagesJSON {
|
|
556
|
+
let tnf: UInt8 = record["tnf"] as? UInt8 ?? 0
|
|
557
|
+
if let type = record["type"] as? [UInt8] {
|
|
558
|
+
if let id = record["id"] as? [UInt8] {
|
|
559
|
+
if let payload = record["payload"] as? [UInt8] {
|
|
560
|
+
records.append(
|
|
561
|
+
NFCNDEFPayload(format: .init(rawValue: tnf) ?? .unknown, type: Data(type), identifier: Data(id), payload: Data(payload))
|
|
562
|
+
)
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
DispatchQueue.main.async {
|
|
570
|
+
|
|
571
|
+
tagReader.writeNDEF(message: .init(records: records), completed: {
|
|
572
|
+
(error:Error?) in
|
|
573
|
+
if (error != nil) {
|
|
574
|
+
self.sendError(command: command, result: error!.localizedDescription)
|
|
575
|
+
return
|
|
576
|
+
}
|
|
577
|
+
self.sendSuccess(command: command)
|
|
578
|
+
})
|
|
579
|
+
|
|
580
|
+
}
|
|
581
|
+
}
|
|
526
582
|
|
|
527
583
|
}
|