NotificationController class abstract

A controller of user notifications allow for creating, scheduling, and canceling user notifications.

This controller serves two purposes:

  1. It is used by the AppTaskController to send notification about UserTasks (which are created based on AppTask in the StudyProtocol). This happens automatically, if the app task is configured to send a notification.

  2. It can be used by the app to create, schedule, and cancel app-specific notifications. This is done using the createNotification, scheduleNotification, and scheduleRecurrentNotifications methods, which creates an immediate, scheduled, or recurrent notification, respectively.

Implementers

Constructors

NotificationController()

Properties

hashCode int
The hash code for this object.
no setterinherited
pendingNotificationRequestsCount Future<int>
The number of pending notifications.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelNotification(int id) Future<void>
Cancel (i.e., remove) the notification with id.
cancelTaskNotification(UserTask task) Future<void>
Cancel (i.e., remove) the notification for the task.
createNotification({int? id, required String title, String? body}) Future<int>
Create an immediate notification with id, title, and body. If the id is not specified, a random id will be generated.
createTaskNotification(UserTask task) Future<void>
Create an immediate notification for a task.
initialize() Future<void>
Initialize and set up the notification controller. Also tries to get permissions to send notifications.
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>
Schedule a notification with id, title, and body at the schedule time. If the id is not specified, a random id will be generated.
scheduleRecurrentNotifications({int? id, required String title, String? body, required RecurrentScheduledTrigger schedule}) Future<int>
Schedule recurrent notifications with id, title, and body at the schedule time.
scheduleTaskNotification(UserTask task) Future<void>
Schedule a notification for a task at the task.triggerTime.
toString() String
A string representation of this object.
inherited

Operators

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

Constants

CHANNEL_DESCRIPTION → const String
The description of the notification channel as shown in the Settings on Android phones.
CHANNEL_ID → const String
The id of the notification channel.
CHANNEL_NAME → const String
The name of the notification channel as shown in the Settings on Android phones.
PENDING_NOTIFICATION_LIMIT → const int
The upper limit of scheduled notification on iOS.
SCHEDULED_CHANNEL_DESCRIPTION → const String
The description of the notification channel as shown in the Settings on Android phones.
SCHEDULED_CHANNEL_ID → const String
The id of the notification channel.
SCHEDULED_CHANNEL_NAME → const String
The name of the notification channel as shown in the Settings on Android phones.