messaging::
Base class used to receive messages from Firebase Cloud Messaging.
A listener that can be polled to consume pending Message
s.
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. |
Error
Error code returned by Firebase Cloud Messaging C++ functions.
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. |
Future<void>DeleteTokenLastResult()
Gets the result of the most recent call to DeleteToken();.
Details | |
---|---|
Returns | Result of the most recent call to DeleteToken(). |
boolDeliveryMetricsExportToBigQueryEnabled()
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. |
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. |
Future<std::string>GetTokenLastResult()
Gets the result of the most recent call to GetToken();.
Details | |
---|---|
Returns | Result of the most recent call to GetToken(). |
InitResultInitialize(constApp&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. |
InitResultInitialize(constApp&app,Listener*listener,constMessagingOptions&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. |
boolIsTokenRegistrationOnInitEnabled()
Determines if automatic token registration during initalization is enabled.
Details | |
---|---|
Returns | true if auto token registration is enabled and false if disabled. |
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. |
Future<void>RequestPermissionLastResult()
Gets the result of the most recent call to RequestPermission();.
Details | |
---|---|
Returns | Result of the most recent call to RequestPermission(). |
voidSetDeliveryMetricsExportToBigQuery(boolenable)
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 |
|
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. |
voidSetTokenRegistrationOnInitEnabled(boolenable)
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-dataandroid:name="firebase_messaging_auto_init_enabled"android:value="false"/>
or on iOS or tvOS to your Info.plist:
<key>FirebaseMessagingAutoInitEnabled</key> <false/>
Details | |||
---|---|---|---|
Parameters |
|
Future<void>Subscribe(constchar*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 |
|
Future<void>SubscribeLastResult()
Gets the result of the most recent call to Unsubscribe();.
Details | |
---|---|
Returns | Result of the most recent call to Unsubscribe(). |
voidTerminate()
Terminate Firebase Cloud Messaging.
Frees resources associated with Firebase Cloud Messaging.
Future<void>Unsubscribe(constchar*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 |
|
Future<void>UnsubscribeLastResult()
Gets the result of the most recent call to Unsubscribe();.
Details | |
---|---|
Returns | Result of the most recent call to Unsubscribe(). |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-26 UTC.