FlutterLocalNotificationManager class
A NotificationManager that shows local notifications using the flutter_local_notifications plugin.
The default notification manager of SmartPhoneClientManager. It shows
notifications for UserTasks (see AppTaskController) and app-specific
notifications. A singleton, accessed as FlutterLocalNotificationManager().
Key points:
- configure must be called before use. It registers the notification icon and asks for notification permission on Android.
- Uses exact alarms on Android when
SCHEDULE_EXACT_ALARMis granted, otherwise inexact alarms. - Task notifications use the hash code of UserTask.id as notification id.
- Taps on task notifications are sent to AppTaskController.onNotification. Other taps are emitted on notificationTaps.
On iOS, remember to edit the AppDelegate.swift file. See https://pub.dev/packages/flutter_local_notifications#general-setup
On Android, update the AndroidManifest.xml and gradle.build files to add
the necessary permissions and service declaration for notifications.
Also add an ic_launcher.png square png picture in the
<<application_name>>/android/app/src/main/res/drawable/ folder.
You can use the default app icon, just make a copy in the drawable folder.
- Implemented types
Constructors
- FlutterLocalNotificationManager()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
notificationTaps
→ Stream<
String> -
The payloads of tapped notifications created with createNotification.
Taps on task notifications are handled by the AppTaskController.
no setteroverride
-
pendingNotificationRequestsCount
→ Future<
int> -
The number of pending notifications.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelNotification(
int id) → Future< void> -
Cancels (i.e., removes) the notification with
id.override -
cancelTaskNotification(
UserTask task) → Future< void> -
Cancels (i.e., removes) the notification for the
task.override -
configure(
) → Future< void> -
Configures and sets up the notification manager.
override
-
createNotification(
{int? id, required String title, String? body, String? payload}) → Future< int> -
Creates an immediate notification with
id,title, andbody. If theidis not specified, a random id will be generated. When tapped,payloadis emitted on notificationTaps.override -
createTaskNotification(
UserTask task) → Future< void> -
Creates an immediate notification for a
task.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scheduleNotification(
{int? id, required String title, String? body, required DateTime schedule}) → Future< int> -
Schedules a notification with
id,title, andbodyat thescheduletime. If theidis not specified, a random id will be generated.override -
scheduleRecurrentNotifications(
{int? id, required String title, String? body, required RecurrentScheduledTrigger schedule}) → Future< int> -
Schedules recurrent notifications with
id,title, andbodyat thescheduletime.override -
scheduleTaskNotification(
UserTask task) → Future< void> -
Schedules a notification for a
taskat its UserTask.triggerTime.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited