FCMNotificationService class

Firebase Cloud Messaging implementation of NotificationService

This implementation uses Firebase Cloud Messaging (FCM) to send push notifications. It requires firebase_messaging dependency to be added to pubspec.yaml.

Optional dependencies:

  • firebase_messaging: ^14.7.10 (for FCM functionality)
  • http: ^1.1.2 (for server-side sending)
Implemented types

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

areNotificationsEnabled() Future<bool>
Check if notifications are enabled/permitted
override
dispose() Future<void>
Clean up resources
override
getDeviceToken() Future<String?>
Get the current device token (for FCM-like providers)
override
getProviderInfo() Map<String, dynamic>
Get provider-specific configuration status
override
initialize() Future<void>
Initialize the notification service
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerUserToken({required String userId, required String token}) Future<void>
Register a device token for a user
override
requestNotificationPermissions() Future<bool>
Request notification permissions from the user
override
sendNotification({required NotificationData data, required NotificationTarget target}) Future<NotificationResult>
Send a notification to specific targets
override
sendToTopic({required String topic, required NotificationData data}) Future<NotificationResult>
Send notification to a topic/channel
override
sendToUser({required String userId, required NotificationData data}) Future<NotificationResult>
Send notification to a single user by their user ID
override
sendToUsers({required List<String> userIds, required NotificationData data}) Future<NotificationResult>
Send notification to multiple users
override
setupNotificationHandlers({dynamic onNotificationClick(Map<String, dynamic> data)?, dynamic onNotificationReceived(NotificationData data)?}) → void
Set up notification click handlers
override
subscribeToTopic({required String userId, required String topic}) Future<void>
Subscribe a user to a topic
override
toString() String
A string representation of this object.
inherited
unregisterUserToken({required String userId, required String token}) Future<void>
Unregister a device token
override
unsubscribeFromTopic({required String userId, required String topic}) Future<void>
Unsubscribe a user from a topic
override

Operators

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