firebase:: messaging
Firebase Cloud Messaging API.
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.
Enumerations |
|
---|---|
Error{
|
enum Error code returned by Firebase Cloud Messaging C++ functions. |
Functions |
|
---|---|
DeleteToken()
|
Future< void >
Deletes the default token for this Firebase project.
|
DeleteTokenLastResult()
|
Future< void >
Gets the result of the most recent call to DeleteToken();.
|
DeliveryMetricsExportToBigQueryEnabled()
|
bool
Determines whether Firebase Cloud Messaging exports message delivery metrics to BigQuery.
|
GetToken()
|
Future< std::string >
This creates a Firebase Installations ID, if one does not exist, and sends information about the application and the device where it's running to the Firebase backend.
|
GetTokenLastResult()
|
Future< std::string >
Gets the result of the most recent call to GetToken();.
|
Initialize(const App & app, Listener *listener)
|
Initialize Firebase Cloud Messaging.
|
Initialize(const App & app, Listener *listener, const MessagingOptions & options)
|
Initialize Firebase Cloud Messaging.
|
IsTokenRegistrationOnInitEnabled()
|
bool
Determines if automatic token registration during initalization is enabled.
|
RequestPermission()
|
Future< void >
Displays a prompt to the user requesting permission to display notifications.
|
RequestPermissionLastResult()
|
Future< void >
Gets the result of the most recent call to RequestPermission();.
|
SetDeliveryMetricsExportToBigQuery(bool enable)
|
void
Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery.
|
SetListener(Listener *listener)
|
Listener *
Set the listener for events from the Firebase Cloud Messaging servers.
|
SetTokenRegistrationOnInitEnabled(bool enable)
|
void
Enable or disable token registration during initialization of Firebase Cloud Messaging.
|
Subscribe(const char *topic)
|
Future< void >
Subscribe to receive all messages to the specified topic.
|
SubscribeLastResult()
|
Future< void >
Gets the result of the most recent call to Unsubscribe();.
|
Terminate()
|
void
Terminate Firebase Cloud Messaging.
|
Unsubscribe(const char *topic)
|
Future< void >
Unsubscribe from a topic.
|
UnsubscribeLastResult()
|
Future< void >
Gets the result of the most recent call to Unsubscribe();.
|
Classes |
|
---|---|
firebase:: |
Base class used to receive messages from Firebase Cloud Messaging. |
firebase:: |
A listener that can be polled to consume pending |
Structs |
|
---|---|
firebase:: |
Data structure for parameters that are unique to the Android implementation. |
firebase:: |
Data structure used to receive messages from cloud messaging. |
firebase:: |
A class to configure the behavior of Firebase Cloud Messaging. |
firebase:: |
Used for messages that display a notification. |
Enumerations
Error
Error
Error code returned by Firebase Cloud Messaging C++ functions.
Functions
DeleteToken
Future< void > DeleteToken()
Deletes the default token for this Firebase project.
Note that this does not delete the Firebase Installations ID that may have been created when generating the token. See Installations.Delete() for deleting that.
Details | |
---|---|
Returns |
A future that completes when the token is deleted.
|
DeleteTokenLastResult
Future< void > DeleteTokenLastResult()
Gets the result of the most recent call to DeleteToken();.
Details | |
---|---|
Returns |
Result of the most recent call to DeleteToken().
|
DeliveryMetricsExportToBigQueryEnabled
bool DeliveryMetricsExportToBigQueryEnabled()
Determines whether Firebase Cloud Messaging exports message delivery metrics to BigQuery.
This function is currently only implemented on Android, and returns false with no other behavior on other platforms.
Details | |
---|---|
Returns |
true if Firebase Cloud Messaging exports message delivery metrics to BigQuery.
|
GetToken
Future< std::string > GetToken()
This creates a Firebase Installations 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 future with the token.
|
GetTokenLastResult
Future< std::string > GetTokenLastResult()
Gets the result of the most recent call to GetToken();.
Details | |
---|---|
Returns |
Result of the most recent call to GetToken().
|
Initialize
InitResult Initialize( const App & app, Listener *listener )
Initialize Firebase Cloud Messaging.
After Initialize is called, the implementation may call functions on the Listener provided at any time.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
|
Initialize
InitResult Initialize( const App & app, Listener *listener, const MessagingOptions & options )
Initialize Firebase Cloud Messaging.
After Initialize is called, the implementation may call functions on the Listener provided at any time.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
kInitResultSuccess if initialization succeeded, or kInitResultFailedMissingDependency on Android if Google Play services is not available on the current device.
|
IsTokenRegistrationOnInitEnabled
bool IsTokenRegistrationOnInitEnabled()
Determines if automatic token registration during initalization is enabled.
Details | |
---|---|
Returns |
true if auto token registration is enabled and false if disabled.
|
RequestPermission
Future< void > RequestPermission()
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 future that completes when the notification prompt has been dismissed.
|
RequestPermissionLastResult
Future< void > RequestPermissionLastResult()
Gets the result of the most recent call to RequestPermission();.
Details | |
---|---|
Returns |
Result of the most recent call to RequestPermission().
|
SetDeliveryMetricsExportToBigQuery
void SetDeliveryMetricsExportToBigQuery( bool enable )
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.
This function is currently only implemented on Android, and has no behavior on other platforms.
Details | |||
---|---|---|---|
Parameters |
|
SetListener
Listener * SetListener( Listener *listener )
Set the listener for events from the Firebase Cloud Messaging servers.
A listener must be set for the application to receive messages from the Firebase Cloud Messaging servers. The implementation may call functions on the Listener provided at any time.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
Pointer to the previously set listener.
|
SetTokenRegistrationOnInitEnabled
void SetTokenRegistrationOnInitEnabled( bool enable )
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/>
Details | |||
---|---|---|---|
Parameters |
|
Subscribe
Future< void > Subscribe( const char *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.
Call this function from the main thread. FCM is not thread safe.
Details | |||
---|---|---|---|
Parameters |
|
SubscribeLastResult
Future< void > SubscribeLastResult()
Gets the result of the most recent call to Unsubscribe();.
Details | |
---|---|
Returns |
Result of the most recent call to Unsubscribe().
|
Terminate
void Terminate()
Terminate Firebase Cloud Messaging.
Frees resources associated with Firebase Cloud Messaging.
Unsubscribe
Future< void > Unsubscribe( const char *topic )
Unsubscribe from a topic.
Unsubscribes an app instance from a topic, stopping it from receiving any further messages sent to that topic.
Call this function from the main thread. FCM is not thread safe.
Details | |||
---|---|---|---|
Parameters |
|
UnsubscribeLastResult
Future< void > UnsubscribeLastResult()
Gets the result of the most recent call to Unsubscribe();.
Details | |
---|---|
Returns |
Result of the most recent call to Unsubscribe().
|