initialize method

Future<void> initialize({
  1. bool enableNotifications = true,
})

Initialize and set up the app controller.

If enableNotifications is true, a notification will be added to the phone's notification system when a task is enqueued via the enqueue method.

Implementation

Future<void> initialize({
  bool enableNotifications = true,
}) async {
  // set up a timer which cleans up in the queue once an hour
  _garbageCollector = Timer.periodic(const Duration(hours: 1), (timer) {
    for (var task in userTasks) {
      if (task.expiresIn != null && task.expiresIn!.isNegative) {
        expire(task.id);
      }
    }
  });

  notificationsEnabled = enableNotifications;
  if (notificationsEnabled) {
    await SmartPhoneClientManager().notificationController?.initialize();
  }
}