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

    The channel uses FlutterStandardMessageCodec to encode and decode messages.

    Declaration

    Objective-C

    + (nonnull instancetype)
    messageChannelWithName:(nonnull NSString *)name
           binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)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 FlutterViewController.

    Declaration

    Objective-C

    + (nonnull instancetype)
    messageChannelWithName:(nonnull NSString *)name
           binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                     codec:(nonnull NSObject<FlutterMessageCodec> *)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 FlutterViewController.

    Declaration

    Objective-C

    - (nonnull instancetype)
       initWithName:(nonnull NSString *)name
    binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
              codec:(nonnull NSObject<FlutterMessageCodec> *)codec;
  • Sends the specified message to the Flutter side, ignoring any reply.

    Declaration

    Objective-C

    - (void)sendMessage:(id _Nullable)message;
  • Sends the specified message to the Flutter side, expecting an asynchronous reply.

    Declaration

    Objective-C

    - (void)sendMessage:(id _Nullable)message
                  reply:(FlutterReply _Nullable)callback;
  • 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;