FlutterBasicMessageChannel

@interface FlutterBasicMessageChannel : NSObject

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

  • 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;

    Parameters

    name

    The channel name.

    messenger

    The binary messenger.

  • 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.

  • 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;

    Parameters

    name

    The channel name.

    messenger

    The binary messenger.

    codec

    The message 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
              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]).

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

    Declaration

    Objective-C

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

    Parameters

    message

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

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

    Declaration

    Objective-C

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

    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.

  • 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;

    Parameters

    handler

    The message handler.

  • 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;