initialize method

Future<bool?> initialize(
  1. MacOSInitializationSettings initializationSettings, {
  2. SelectNotificationCallback? onSelectNotification,
})

Initializes the plugin.

Call this method on application before using the plugin further. This should only be done once. When a notification created by this plugin was used to launch the app, calling initialize is what will trigger to the onSelectNotification callback to be fire.

Initialisation may also request notification permissions where users will see a permissions prompt. This may be fine in cases where it's acceptable to do this when the application runs for the first time. However, if your applicationn needs to do this at a later point in time, set the MacOSInitializationSettings.requestAlertPermission, MacOSInitializationSettings.requestBadgePermission and MacOSInitializationSettings.requestSoundPermission values to false. requestPermissions can then be called to request permissions when needed.

To handle when a notification launched an application, use getNotificationAppLaunchDetails.

Implementation

Future<bool?> initialize(
  MacOSInitializationSettings initializationSettings, {
  SelectNotificationCallback? onSelectNotification,
}) async {
  _onSelectNotification = onSelectNotification;
  _channel.setMethodCallHandler(_handleMethod);
  return await _channel.invokeMethod(
      'initialize', initializationSettings.toMap());
}