Contents

messageReceived(_:completion:)

Handles incoming messages for transmission to the accessory.

Declaration

func messageReceived(_ message: TransportMessage, completion: @escaping  @Sendable (AccessoryMessage.Result) -> Void)

Parameters

  • message:

    A transport message containing data to send to the accessory.

  • completion:

    A closure to call when message transmission completes.

Mentioned in

Discussion

The system calls this method to deliver encrypted notification data for transmission to your accessory. Relay the message’s data to your accessory over Bluetooth or another transport. Call the completion handler with AccessoryMessage.Result.success if transmission succeeds, AccessoryMessage.Result.failure(_:) with AccessoryMessage.Error.transportFailed if the transport fails but may recover, or AccessoryMessage.Error.transportUnavailable if the transport is unavailable.

If you don’t call the completion handler, the system assumes successful delivery and won’t retry the message.

See Also

Handling data events