Firebase. Messaging. FirebaseMessaging
Summary
Firebase Cloud Messaging allows you to send data from your server to your users' devices, and receive messages from devices on the same connection if you're using a XMPP server.
The FCM service handles all aspects of queueing of messages and delivery to client applications running on target devices.
Properties |
|
|---|---|
DeliveryMetricsExportedToBigQueryEnabled
|
static bool
|
RegistrationOnInitEnabled
|
static bool
|
TokenRegistrationOnInitEnabled
|
static bool
|
Events |
|
|---|---|
MessageReceived
|
static System.EventHandler< MessageReceivedEventArgs >
Called on the client when a message arrives.
|
RegistrationReceived
|
static System.EventHandler< RegistrationReceivedEventArgs >
Called on the client when a registration installation ID arrives or changes.
|
TokenReceived
|
static System.EventHandler< TokenReceivedEventArgs >
Called on the client when a registration token message arrives.
|
UnregistrationReceived
|
static System.EventHandler< UnregistrationReceivedEventArgs >
Called on the client when an unregistration confirmation arrives.
|
Public static functions |
|
|---|---|
DeleteTokenAsync()
|
System.Threading.Tasks.Task
Deletes the default token for this Firebase project.
|
GetTokenAsync()
|
System.Threading.Tasks.Task< string >
This creates a FirebaseInstallations ID, if one does not exist, and sends information about the application and the device where it's running to the Firebase backend.
|
RegisterAsync()
|
System.Threading.Tasks.Task
|
RequestPermissionAsync()
|
System.Threading.Tasks.Task
Displays a prompt to the user requesting permission to display notifications.
|
SubscribeAsync(string topic)
|
System.Threading.Tasks.Task
Subscribe to receive all messages to the specified topic.
|
UnregisterAsync()
|
System.Threading.Tasks.Task
Unregisters the current app instance with FCM.
|
UnsubscribeAsync(string topic)
|
System.Threading.Tasks.Task
Unsubscribe from a topic.
|
Properties
DeliveryMetricsExportedToBigQueryEnabled
static bool DeliveryMetricsExportedToBigQueryEnabled
Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery.
By default, message delivery metrics are not exported to BigQuery. Use this method to enable or disable the export at runtime. In addition, you can enable the export by adding to your manifest. Note that the run-time method call will override the manifest value.
RegistrationOnInitEnabled
static bool RegistrationOnInitEnabled
Enable or disable registration during initialization of Firebase Cloud Messaging.
The installation ID returned is what identifies the user to Firebase, so disabling this avoids creating any new identity and automatically sending it to Firebase, unless consent has been granted.
If this setting is enabled, it triggers the registration refresh immediately. This setting is persisted across app restarts and overrides the setting "firebase_messaging_auto_init_enabled" specified in your Android manifest (on Android) or Info.plist (on iOS and tvOS).
By default, registration during initialization is enabled.
The registration happens before you can programmatically disable it, so if you need to change the default, (for example, because you want to prompt the user before FCM generates/refreshes a registration on app startup), add to your application’s manifest:
<meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" />
or on iOS or tvOS to your Info.plist:
<key>FirebaseMessagingAutoInitEnabled</key> <false/>
TokenRegistrationOnInitEnabled
static bool TokenRegistrationOnInitEnabled
Enable or disable token registration during initialization of Firebase Cloud Messaging.
This token is what identifies the user to Firebase, so disabling this avoids creating any new identity and automatically sending it to Firebase, unless consent has been granted.
If this setting is enabled, it triggers the token registration refresh immediately. This setting is persisted across app restarts and overrides the setting "firebase_messaging_auto_init_enabled" specified in your Android manifest (on Android) or Info.plist (on iOS and tvOS).
By default, token registration during initialization is enabled.
The registration happens before you can programmatically disable it, so if you need to change the default, (for example, because you want to prompt the user before FCM generates/refreshes a registration token on app startup), add to your application’s manifest:
<meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" />
or on iOS or tvOS to your Info.plist:
<key>FirebaseMessagingAutoInitEnabled</key> <false/>
Events
MessageReceived
static System.EventHandler< MessageReceivedEventArgs > MessageReceived
Called on the client when a message arrives.
RegistrationReceived
static System.EventHandler< RegistrationReceivedEventArgs > RegistrationReceived
Called on the client when a registration installation ID arrives or changes.
TokenReceived
static System.EventHandler< TokenReceivedEventArgs > TokenReceived
Called on the client when a registration token message arrives.
UnregistrationReceived
static System.EventHandler< UnregistrationReceivedEventArgs > UnregistrationReceived
Called on the client when an unregistration confirmation arrives.
Public static functions
DeleteTokenAsync
System.Threading.Tasks.Task DeleteTokenAsync()
Deletes the default token for this Firebase project.
Note that this does not delete the FirebaseInstallations ID that may have been created when generating the token. See Installations.Delete() for deleting that.
| Details | |
|---|---|
| Returns |
A task that completes when the token is deleted.
|
GetTokenAsync
System.Threading.Tasks.Task< string > GetTokenAsync()
This creates a FirebaseInstallations ID, if one does not exist, and sends information about the application and the device where it's running to the Firebase backend.
| Details | |
|---|---|
| Returns |
A task with the token.
|
RegisterAsync
System.Threading.Tasks.Task RegisterAsync()
Registers the current Firebase app instance with the Firebase Cloud Messaging (FCM) backend to receive messages.
This creates a FirebaseInstallations ID (FID), if one does not exist, and sends information about the application and the device where it's running to the Firebase backend.
Upon completion, RegistrationReceived will be triggered with the current FID. Calling this function when already registered will still invoke the RegistrationReceived callback with the existing FID.
| Details | |
|---|---|
| Returns |
A task that completes when the registration is completed.
|
RequestPermissionAsync
System.Threading.Tasks.Task RequestPermissionAsync()
Displays a prompt to the user requesting permission to display notifications.
The permission prompt only appears on iOS and tvOS. If the user has already agreed to allow notifications, no prompt is displayed and the returned future is completed immediately.
| Details | |
|---|---|
| Returns |
A Task that completes when the notification prompt has been dismissed.
|
SubscribeAsync
System.Threading.Tasks.Task SubscribeAsync( string topic )
Subscribe to receive all messages to the specified topic.
Subscribes an app instance to a topic, enabling it to receive messages sent to that topic.
| Details | |||
|---|---|---|---|
| Parameters |
|
UnregisterAsync
System.Threading.Tasks.Task UnregisterAsync()
Unregisters the current app instance with FCM.
Note that this does not delete the FirebaseInstallations ID that may have been created during registration. See Installations.Delete() for deleting that.
| Details | |
|---|---|
| Returns |
A task that completes when the unregistration is completed.
|
UnsubscribeAsync
System.Threading.Tasks.Task UnsubscribeAsync( string topic )
Unsubscribe from a topic.
Unsubscribes an app instance from a topic, stopping it from receiving any further messages sent to that topic.
| Details | |||
|---|---|---|---|
| Parameters |
|