NotificationMasterWeb class
A web implementation of the NotificationMasterPlatform of the NotificationMaster plugin.
This implementation uses the package:web library to interact with the
browser's Notification API.
Usage example:
// In your main.dart or where you initialize your app
void main() {
// The web implementation is automatically registered
runApp(MyApp());
}
// Later in your code
final notificationMaster = NotificationMaster();
await notificationMaster.requestNotificationPermission();
await notificationMaster.showNotification(
title: 'Hello Web',
message: 'This is a notification on the web!',
);
- Inheritance
-
- Object
- PlatformInterface
- NotificationMasterPlatform
- NotificationMasterWeb
Constructors
- NotificationMasterWeb()
- Constructs a NotificationMasterWeb
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
-
cancelAllScheduledNotifications(
) → Future< bool> -
Cancel every notification that was scheduled through scheduleNotification.
override
-
cancelScheduledNotification(
int id) → Future< bool> -
Cancel a previously scheduled notification by its
id.override -
canScheduleExactAlarms(
) → Future< bool> -
Android 12+: whether the app may schedule exact alarms.
Other platforms return
true.inherited -
checkNotificationPermission(
) → Future< bool> -
Check if notification permission is granted.
override
-
createCustomChannel(
{required String channelId, required String channelName, String? channelDescription, int? importance, bool? enableLights, int? lightColor, bool? enableVibration, bool? enableSound}) → Future< bool> -
Create a custom notification channel.
override
-
getActiveNotificationService(
) → Future< String> -
Get the currently active notification service.
override
-
getDeviceToken(
) → Future< String?> -
Returns a stable pseudo-token from localStorage; generates one on first call.
override
-
getPendingScheduledNotifications(
) → Future< List< int> > -
Returns the ids of notifications that are scheduled but not yet delivered.
override
-
getPlatformVersion(
) → Future< String?> -
Returns a String containing the version of the platform.
override
-
getSubscribedTopics(
) → Future< List< String> > -
Returns the list of topics stored in localStorage.
override
-
isBackgroundPollingRunning(
) → Future< bool> -
Whether the background poller process is currently running.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openAppNotificationSettings(
) → Future< bool> -
Opens app notification settings (Android). User must grant manually.
inherited
-
openExactAlarmSettings(
) → Future< bool> -
Opens system Settings for "Alarms & reminders" (Android).
User must grant manually. No-op /
falseon other platforms.inherited -
requestNotificationPermission(
) → Future< bool> -
Request notification permission.
override
-
scheduleNotification(
{required int id, required String title, required String message, required int scheduledEpochMillis, String? channelId, NotificationImportance? importance, bool alarmSound = false, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<bool> -
Schedule a notification to be delivered by the operating system at a
specific point in time, even when the app is fully closed.
override
-
setFirebaseAsActiveService(
) → Future< bool> -
Set Firebase Cloud Messaging as the active notification service.
override
-
showBigTextNotification(
{required String title, required String message, required String bigText, String? channelId, NotificationImportance? importance, bool? autoCancel, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<int> -
Show a notification with big text style.
override
-
showFullScreenNotification(
{required String title, required String message, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<int> -
inherited
-
showHeadsUpNotification(
{required String title, required String message, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<int> -
inherited
-
showImageNotification(
{required String title, required String message, required String imageUrl, String? channelId, NotificationImportance? importance, bool? autoCancel, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<int> -
Show a notification with an image.
override
-
showNotification(
{int? id, required String title, required String message, String? channelId, NotificationImportance? importance, bool? autoCancel, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<int> -
Show a simple notification.
override
-
showNotificationWithActions(
{required String title, required String message, required List< Map< actions, String? channelId, NotificationImportance? importance, bool? autoCancel, String? targetScreen, Map<String, String> >String, dynamic> ? extraData}) → Future<int> -
Show a notification with custom actions.
override
-
showStyledNotification(
{required String title, required String message, String? channelId, String? targetScreen, Map< String, dynamic> ? extraData}) → Future<int> -
inherited
-
startBackgroundPollingService(
{required String pollingUrl, int? intervalMinutes}) → Future< bool> -
Start a standalone background poller process that keeps polling
pollingUrland showing toasts even after the app is fully closed (Windows only).override -
startForegroundService(
{required String pollingUrl, int? intervalMinutes, String? channelId}) → Future< bool> -
Start a foreground service for continuous notification polling.
override
-
startNotificationPolling(
{required String pollingUrl, int? intervalMinutes}) → Future< bool> -
Start polling for notifications from a remote server.
override
-
stopBackgroundPollingService(
) → Future< bool> -
Stop the background poller process started via startBackgroundPollingService.
override
-
stopForegroundService(
) → Future< bool> -
Stop the foreground service for notification polling.
override
-
stopNotificationPolling(
) → Future< bool> -
Stop polling for notifications.
override
-
subscribeToTopic(
String topic) → Future< bool> -
Subscribes to a topic by persisting it in localStorage and shows a notification.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribeFromTopic(
String topic) → Future< bool> -
Unsubscribes from a topic and shows a confirmation notification.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
registerWith(
Registrar registrar) → void