writeNDEF(_:completionHandler:)
Saves an NDEF message to a writable tag.
Declaration
func writeNDEF(_ ndefMessage: NFCNDEFMessage, completionHandler: @escaping @Sendable ((any Error)?) -> Void)func writeNDEF(_ ndefMessage: NFCNDEFMessage) async throwsParameters
- ndefMessage:
The NDEF message to write to the tag.
- completionHandler:
The handler invoked by the reader session after completing the write request. The session calls
completionHandleron the dispatch queue provided when creating the Nfcndefreadersession.The handler has the following parameter:
- error
An Nserror object if the write request fails. A value of
nilindicates that the write was successful.
Discussion
To determine whether the tag is writable, call queryNDEFStatus(completionHandler:) and check that the status is NFCNDEFStatus.readWrite.