-
What's new in Core NFC
Core NFC helps you scan and write to NFC tags in your apps, helping people get more from objects like parking meters, scooter rentals, car charging stations, and more. Learn about Core NFC's support for the ISO15693 protocol and new tag capabilities, and find out more about syntax improvements for Swift.
Ressources
Vidéos connexes
WWDC19
-
Rechercher dans cette vidéo…
-
-
3:24 - sendCommand
detectedTag.sendCommand(apdu: apdu) { (result: Result<NFCISO7816ResponseAPDU, Error>) in switch result { case .success(let responseAPDU): /// Handle NFCISO7816ResponseAPDU object. case .failure(let error): /// Handle Error object. } } -
4:06 - sendMiFareCommand
// You need to zero-pad the data to fill the block size if blockData.count < blockSize { blockData += Data(count: blockSize - blockData.count) } let writeCommand = Data([writeBlockCommand, offset]) + blockData tag.sendMiFareCommand(commandPacket: writeCommand) { (response: Result<Data, Error>) in switch (response) { case .success(let responseData): if responseData[0] != successCode { self.readerSession?.invalidate(errorMessage: "Write tag error. Please try again.") return } let newSize = data.count - blockSize if newSize > 0 { self.write(data.suffix(newSize), to: tag, offset: (offset + 1)) } else { self.readerSession?.invalidate() } case .failure(let error): let message = "Write tag error: \(error.localizedDescription). Please try again." self.readerSession?.invalidate(errorMessage: message) } }
-