# FlutterBinaryMessenger

Objective-C

    @protocol FlutterBinaryMessenger <NSObject>

Swift

    protocol FlutterBinaryMessenger : NSObjectProtocol

A facility for communicating with the Flutter side using asynchronous message passing with binary messages.

Implementated by:

- `FlutterBasicMessageChannel`, which supports communication using structured messages.
- `FlutterMethodChannel`, which supports communication using asynchronous method calls.
- `FlutterEventChannel`, which supports commuication using event streams.

- `-makeBackgroundTaskQueue`

  Undocumented

  #### Declaration

  Objective-C

      - (NSObject<FlutterTaskQueue>*)makeBackgroundTaskQueue;

- `-setMessageHandlerOnChannel:binaryMessageHandler:taskQueue:`

  Undocumented

  #### Declaration

  Objective-C

      - (FlutterBinaryMessengerConnection)
          setMessageHandlerOnChannel:(NSString*)channel
                binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler
                           taskQueue:(NSObject<FlutterTaskQueue>* _Nullable)taskQueue;

- `-sendOnChannel:message:`

  Sends a binary message to the Flutter side on the specified channel, expecting no reply.

  #### Declaration

  Objective-C

      - (void)sendOnChannel:(nonnull NSString *)channel
                    message:(NSData *_Nullable)message;

  Swift

      func send(onChannel channel: String, message: Data?)

  #### Parameters

  `channel` | The channel name.
  `message` | The message.

- `-sendOnChannel:message:binaryReply:`

  Sends a binary message to the Flutter side on the specified channel, expecting an asynchronous reply.

  #### Declaration

  Objective-C

      - (void)sendOnChannel:(nonnull NSString *)channel
                    message:(NSData *_Nullable)message
                binaryReply:(FlutterBinaryReply _Nullable)callback;

  Swift

      func send(onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply? = nil)

  #### Parameters

  `channel` | The channel name.
  `message` | The message.
  `callback` | A callback for receiving a reply.

- `-setMessageHandlerOnChannel:binaryMessageHandler:`

  Registers a message handler for incoming binary messages from the Flutter side on the specified channel.

  Replaces any existing handler. Use a `nil` handler for unregistering the existing handler.

  #### Declaration

  Objective-C

      - (FlutterBinaryMessengerConnection)
          setMessageHandlerOnChannel:(nonnull NSString *)channel
                binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler;

  Swift

      func setMessageHandlerOnChannel(_ channel: String, binaryMessageHandler handler: FlutterBinaryMessageHandler? = nil) -> FlutterBinaryMessengerConnection

  #### Parameters

  `channel` | The channel name.
  `handler` | The message handler.

  #### Return Value

  An identifier that represents the connection that was just created to the channel.

- `-cleanUpConnection:`

  Clears out a channel’s message handler if that handler is still the one that was created as a result of `setMessageHandlerOnChannel:binaryMessageHandler:`.

  #### Declaration

  Objective-C

      - (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection;

  Swift

      func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection)

  #### Parameters

  `connection` | The result from `setMessageHandlerOnChannel:binaryMessageHandler:`.

© 2023 Flutter. All rights reserved. (Last updated: 2023-01-31)

Generated by jazzy ♪♫ v0.14.3, a Realm project.