FirebaseMessaging class

The FirebaseMessaging entry point.

To get a new instance, call FirebaseMessaging.instance.

Inheritance
  • Object
  • PlatformInterface
  • FirebasePluginPlatform
  • FirebaseMessaging

Properties

app FirebaseApp
The FirebaseApp for this current FirebaseMessaging instance.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isAutoInitEnabled bool
Returns whether messaging auto initialization is enabled or disabled for the device.
no setter
onTokenRefresh Stream<String>
Fires when a new FCM token is generated.
no setter
pluginConstants Map
Returns any plugin constants this plugin app instance has initialized.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

deleteToken() Future<void>
Removes access to an FCM token previously authorized.
getAPNSToken() Future<String?>
On iOS/MacOS, it is possible to get the users APNs token.
getInitialMessage() Future<RemoteMessage?>
If the application has been opened from a terminated state via a RemoteMessage (containing a Notification), it will be returned, otherwise it will be null.
getNotificationSettings() Future<NotificationSettings>
Returns the current NotificationSettings.
getToken({String? vapidKey}) Future<String?>
Returns the default FCM token for this device.
isSupported() Future<bool>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
requestPermission({bool alert = true, bool announcement = false, bool badge = true, bool carPlay = false, bool criticalAlert = false, bool provisional = false, bool sound = true}) Future<NotificationSettings>
Prompts the user for notification permissions.
sendMessage({String? to, Map<String, String>? data, String? collapseKey, String? messageId, String? messageType, int? ttl}) Future<void>
Send a new RemoteMessage to the FCM server. Android only. Firebase will decommission in June 2024: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessaging#send
setAutoInitEnabled(bool enabled) Future<void>
Enable or disable auto-initialization of Firebase Cloud Messaging.
setDeliveryMetricsExportToBigQuery(bool enabled) Future<void>
Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery for Android.
setForegroundNotificationPresentationOptions({bool alert = false, bool badge = false, bool sound = false}) Future<void>
Sets the presentation options for Apple notifications when received in the foreground.
subscribeToTopic(String topic) Future<void>
Subscribe to topic in background.
toString() String
A string representation of this object.
inherited
unsubscribeFromTopic(String topic) Future<void>
Unsubscribe from topic in background.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance FirebaseMessaging
Returns an instance using the default FirebaseApp.
no setter
onMessage Stream<RemoteMessage>
Returns a Stream that is called when an incoming FCM payload is received whilst the Flutter instance is in the foreground.
no setter
onMessageOpenedApp Stream<RemoteMessage>
Returns a Stream that is called when a user presses a notification message displayed via FCM.
no setter

Static Methods

onBackgroundMessage(BackgroundMessageHandler handler) → void
Set a message handler function which is called when the app is in the background or terminated.