sendBroadcastMessage method

Future<void> sendBroadcastMessage({
  1. required String message,
  2. String type = "chat",
  3. HMSActionResultListener? hmsActionResultListener,
})

Sends a message to everyone on the call.

Parameters:

message - contains the content of the message.

type - The type of the message, default is chat.

hmsActionResultListener - It contain informs about whether the message was successfully sent, or the kind of error if not.

Refer sendBroadcastMesssage guide here

Implementation

Future<void> sendBroadcastMessage(
    {required String message,
    String type = "chat",
    HMSActionResultListener? hmsActionResultListener}) async {
  var arguments = {"message": message, "type": type};
  var result = await PlatformService.invokeMethod(
      PlatformMethod.sendBroadcastMessage,
      arguments: arguments);

  if (hmsActionResultListener != null) {
    if (result != null && result["error"] != null) {
      hmsActionResultListener.onException(
          methodType: HMSActionResultListenerMethod.sendBroadcastMessage,
          arguments: arguments,
          hmsException: HMSException.fromMap(result["error"]));
    } else {
      hmsActionResultListener.onSuccess(
          methodType: HMSActionResultListenerMethod.sendBroadcastMessage,
          arguments: _hmsMessageToMap(result));
    }
  }
}