sendEachForMulticast method

Future<BatchResponse> sendEachForMulticast(
  1. MulticastMessage message, {
  2. bool? dryRun,
})

Sends the given multicast message to all the FCM registration tokens specified in it.

This method uses the Messaging.sendEach API under the hood to send the given message to all the target recipients. The responses list obtained from the return value corresponds to the order of tokens in the MulticastMessage. An error from this method or a BatchResponse with all failures indicates a total failure, meaning that the messages in the list could be sent. Partial failures or failures are only indicated by a BatchResponse return value.

  • message: A multicast message containing up to 500 tokens.
  • dryRun: Whether to send the message in the dry-run (validation only) mode.

Implementation

Future<BatchResponse> sendEachForMulticast(
  MulticastMessage message, {
  bool? dryRun,
}) {
  return sendEach(
    message.tokens
        .map(
          (token) => TokenMessage(
            token: token,
            data: message.data,
            notification: message.notification,
            android: message.android,
            apns: message.apns,
            fcmOptions: message.fcmOptions,
            webpush: message.webpush,
          ),
        )
        .toList(),
    dryRun: dryRun,
  );
}