NotificationManager class

Factory and manager class for push notifications

This class implements the Factory Pattern to create appropriate notification service instances based on configuration. It also acts as a facade to provide a simple interface for the chat system.

Properties

currentService NotificationService?
Get current notification service (for advanced usage)
no setter
hashCode int
The hash code for this object.
no setterinherited
isConfigured bool
Check if notifications are configured and available
no setter
providerInfo Map<String, dynamic>?
Get current provider information
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

areNotificationsEnabled() Future<bool>
Check if notifications are enabled
configure({required NotificationConfig config, bool autoInitialize = true}) Future<void>
Initialize notification system with a specific provider
dispose() Future<void>
Dispose the notification manager and clean up resources
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyTopic({required String topic, required String title, required String body, Map<String, dynamic>? data, String? imageUrl}) Future<NotificationResult>
Send notification to a topic/channel
notifyUser({required String userId, required String title, required String body, Map<String, dynamic>? data, String? imageUrl}) Future<NotificationResult>
Simple method to send notification to a user
notifyUsers({required List<String> userIds, required String title, required String body, Map<String, dynamic>? data, String? imageUrl}) Future<NotificationResult>
Send notification to multiple users
registerCurrentUser(String userId) Future<void>
Register current user's device for notifications
requestPermissions() Future<bool>
Request notification permissions
setupHandlers({dynamic onNotificationClick(Map<String, dynamic> data)?, dynamic onNotificationReceived(NotificationData data)?}) → void
Set up notification handlers for the app
subscribeToTopic({required String userId, required String topic}) Future<void>
Subscribe to a topic
switchProvider({required NotificationConfig newConfig, bool autoInitialize = true}) Future<void>
Switch to a different notification provider
toString() String
A string representation of this object.
inherited
unsubscribeFromTopic({required String userId, required String topic}) Future<void>
Unsubscribe from a topic

Operators

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

Static Properties

instance NotificationManager
Singleton instance
no setter
supportedProviders List<NotificationProvider>
Get supported providers list
no setter

Static Methods

fcmConfig({String? serverKey, String? vapidKey, String? senderId}) FCMNotificationConfig
Helper method to create FCM configuration
oneSignalConfig({required String appId, String? apiKey, String? userAuthKey}) OneSignalNotificationConfig
Helper method to create OneSignal configuration