send method
Sends the given message via FCM.
message
- The message payload.dryRun
- Whether to send the message in the dry-run (validation only) mode.
Returns a unique message ID string after the message has been successfully handed off to the FCM service for delivery.
Implementation
Future<String> send(Message message, {bool? dryRun}) {
return _requestHandler.v1(
(client) async {
final response = await client.projects.messages.send(
fmc1.SendMessageRequest(
message: message._toProto(),
validateOnly: dryRun,
),
_parent,
);
final name = response.name;
if (name == null) {
throw FirebaseMessagingAdminException(
MessagingClientErrorCode.internalError,
'No name in response',
);
}
return name;
},
);
}