FirebaseAdmin.Messaging.FirebaseMessaging

This is the entry point to all server-side Firebase Cloud Messaging (FCM) operations.

Summary

You can get an instance of this class via FirebaseMessaging.DefaultInstance.

Inheritance

Inherits from: FirebaseAdmin.IFirebaseService

Properties

DefaultInstance
Gets the messaging instance associated with the default Firebase app.

Public static functions

GetMessaging(FirebaseApp app)
Returns the messaging instance for the specified app.

Public functions

SendAsync(Message message)
async Task< string >
Sends a message to the FCM service for delivery.
SendAsync(Message message, CancellationToken cancellationToken)
async Task< string >
Sends a message to the FCM service for delivery.
SendAsync(Message message, bool dryRun)
async Task< string >
Sends a message to the FCM service for delivery.
SendAsync(Message message, bool dryRun, CancellationToken cancellationToken)
async Task< string >
Sends a message to the FCM service for delivery.

Properties

DefaultInstance

static FirebaseMessaging DefaultInstance

Gets the messaging instance associated with the default Firebase app.

This property is null if the default app doesn't yet exist.

Public static functions

GetMessaging

FirebaseMessaging GetMessaging(
  FirebaseApp app
)

Returns the messaging instance for the specified app.

Details
Exceptions
System.ArgumentNullException
If the app argument is null.
Parameters
app
An app instance.
Returns
The FirebaseMessaging instance associated with the specified app.

Public functions

SendAsync

async Task< string > SendAsync(
  Message message
)

Sends a message to the FCM service for delivery.

The message gets validated both by the Admin SDK, and the remote FCM service. A successful return value indicates that the message has been successfully sent to FCM, where it has been accepted by the FCM service.

Details
Exceptions
ArgumentNullException
If the message argument is null.
ArgumentException
If the message contains any invalid fields.
FirebaseException
If an error occurs while sending the message.
Parameters
message
The message to be sent. Must not be null.
Returns
A task that completes with a message ID string, which represents successful handoff to FCM.

SendAsync

async Task< string > SendAsync(
  Message message,
  CancellationToken cancellationToken
)

Sends a message to the FCM service for delivery.

The message gets validated both by the Admin SDK, and the remote FCM service. A successful return value indicates that the message has been successfully sent to FCM, where it has been accepted by the FCM service.

Details
Exceptions
ArgumentNullException
If the message argument is null.
ArgumentException
If the message contains any invalid fields.
FirebaseException
If an error occurs while sending the message.
Parameters
message
The message to be sent. Must not be null.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a message ID string, which represents successful handoff to FCM.

SendAsync

async Task< string > SendAsync(
  Message message,
  bool dryRun
)

Sends a message to the FCM service for delivery.

The message gets validated both by the Admin SDK, and the remote FCM service. A successful return value indicates that the message has been successfully sent to FCM, where it has been accepted by the FCM service.

If the dryRun option is set to true, the message will not be actually sent to the recipients. Instead, the FCM service performs all the necessary validations, and emulates the send operation. This is a good way to check if a certain message will be accepted by FCM for delivery.

Details
Exceptions
ArgumentNullException
If the message argument is null.
ArgumentException
If the message contains any invalid fields.
FirebaseException
If an error occurs while sending the message.
Parameters
message
The message to be sent. Must not be null.
dryRun
A boolean indicating whether to perform a dry run (validation only) of the send. If set to true, the message will be sent to the FCM backend service, but it will not be delivered to any actual recipients.
Returns
A task that completes with a message ID string, which represents successful handoff to FCM.

SendAsync

async Task< string > SendAsync(
  Message message,
  bool dryRun,
  CancellationToken cancellationToken
)

Sends a message to the FCM service for delivery.

The message gets validated both by the Admin SDK, and the remote FCM service. A successful return value indicates that the message has been successfully sent to FCM, where it has been accepted by the FCM service.

If the dryRun option is set to true, the message will not be actually sent to the recipients. Instead, the FCM service performs all the necessary validations, and emulates the send operation. This is a good way to check if a certain message will be accepted by FCM for delivery.

Details
Exceptions
ArgumentNullException
If the message argument is null.
ArgumentException
If the message contains any invalid fields.
FirebaseException
If an error occurs while sending the message.
Parameters
message
The message to be sent. Must not be null.
dryRun
A boolean indicating whether to perform a dry run (validation only) of the send. If set to true, the message will be sent to the FCM backend service, but it will not be delivered to any actual recipients.
cancellationToken
A cancellation token to monitor the asynchronous operation.
Returns
A task that completes with a message ID string, which represents successful handoff to FCM.

Send feedback about...

Need help? Visit our support page.