Contents

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 throws

Parameters

  • 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 completionHandler on 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 nil indicates that the write was successful.

Discussion

To determine whether the tag is writable, call queryNDEFStatus(completionHandler:) and check that the status is NFCNDEFStatus.readWrite.

See Also

Writing to the Tag