# FlutterBasicMessageChannel

Objective-C

    @interface FlutterBasicMessageChannel : NSObject

Swift

    class FlutterBasicMessageChannel : NSObject

A channel for communicating with the Flutter side using basic, asynchronous message passing.

- `+messageChannelWithName:binaryMessenger:`

  Creates a `FlutterBasicMessageChannel` with the specified name and binary messenger.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterEngine` and `FlutterViewController`.

  The channel uses `FlutterStandardMessageCodec` to encode and decode messages.

  #### Declaration

  Objective-C

      + (nonnull instancetype)messageChannelWithName:(nonnull NSString *)name
                                     binaryMessenger:
                                         (nonnull NSObject<FlutterBinaryMessenger> *)
                                             messenger;

  Swift

      convenience init(name: String, binaryMessenger messenger: FlutterBinaryMessenger)

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.

- `+messageChannelWithName:binaryMessenger:codec:`

  Creates a `FlutterBasicMessageChannel` with the specified name, binary messenger, and message codec.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterEngine` and `FlutterViewController`.

  #### Declaration

  Objective-C

      + (nonnull instancetype)
          messageChannelWithName:(nonnull NSString *)name
                 binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                           codec:(nonnull NSObject<FlutterMessageCodec> *)codec;

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The message codec.

- `-initWithName:binaryMessenger:codec:`

  Initializes a `FlutterBasicMessageChannel` with the specified name, binary messenger, and message codec.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterEngine` and `FlutterViewController`.

  #### Declaration

  Objective-C

      - (nonnull instancetype)
             initWithName:(nonnull NSString *)name
          binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                    codec:(nonnull NSObject<FlutterMessageCodec> *)codec;

  Swift

      init(name: String, binaryMessenger messenger: FlutterBinaryMessenger, codec: FlutterMessageCodec & NSObjectProtocol)

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The message codec.

- `-initWithName:binaryMessenger:codec:taskQueue:`

  Initializes a `FlutterBasicMessageChannel` with the specified name, binary messenger, and message codec.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterEngine` and `FlutterViewController`.

  #### Declaration

  Objective-C

      - (nonnull instancetype)
             initWithName:(nonnull NSString *)name
          binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                    codec:(nonnull NSObject<FlutterMessageCodec> *)codec
                taskQueue:(NSObject<FlutterTaskQueue> *_Nullable)taskQueue;

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The message codec.
  `taskQueue` | The FlutterTaskQueue that executes the handler (see -[FlutterBinaryMessenger makeBackgroundTaskQueue]).

- `-sendMessage:`

  Sends the specified message to the Flutter side, ignoring any reply.

  #### Declaration

  Objective-C

      - (void)sendMessage:(id _Nullable)message;

  Swift

      func sendMessage(_ message: Any?)

  #### Parameters

  `message` | The message. Must be supported by the codec of this channel.

- `-sendMessage:reply:`

  Sends the specified message to the Flutter side, expecting an asynchronous reply.

  #### Declaration

  Objective-C

      - (void)sendMessage:(id _Nullable)message
                    reply:(FlutterReply _Nullable)callback;

  Swift

      func sendMessage(_ message: Any?) async -> Any?

  #### Parameters

  `message` | The message. Must be supported by the codec of this channel.
  `callback` | A callback to be invoked with the message reply from Flutter.

- `-setMessageHandler:`

  Registers a message handler with this channel.

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

  #### Declaration

  Objective-C

      - (void)setMessageHandler:(FlutterMessageHandler _Nullable)handler;

  Swift

      func setMessageHandler(_ handler: FlutterMessageHandler?)

  #### Parameters

  `handler` | The message handler.

- `-resizeChannelBuffer:`

  Adjusts the number of messages that will get buffered when sending messages to channels that aren’t fully set up yet. For example, the engine isn’t running yet or the channel’s message handler isn’t set up on the Dart side yet.

  #### Declaration

  Objective-C

      - (void)resizeChannelBuffer:(NSInteger)newSize;

  Swift

      func resizeBuffer(_ newSize: Int)

© 2023 Flutter. All rights reserved. (Last updated: 2023-05-23)

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