initialize method

Future<bool> initialize(
  1. AndroidInitializationSettings initializationSettings, {
  2. DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse,
  3. DidReceiveBackgroundNotificationResponseCallback? onDidReceiveBackgroundNotificationResponse,
})

Initializes the plugin.

Call this method on application before using the plugin further.

The onDidReceiveNotificationResponse callback is fired when the user selects a notification or notification action that should show the application/user interface. application was running. To handle when a notification launched an application, use getNotificationAppLaunchDetails. For notification actions that don't show the application/user interface, the onDidReceiveBackgroundNotificationResponse callback is invoked on a background isolate. Functions passed to the onDidReceiveBackgroundNotificationResponse callback need to be annotated with the @pragma('vm:entry-point') annotation to ensure they are not stripped out by the Dart compiler.

Implementation

Future<bool> initialize(
  AndroidInitializationSettings initializationSettings, {
  DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse,
  DidReceiveBackgroundNotificationResponseCallback?
      onDidReceiveBackgroundNotificationResponse,
}) async {
  _ondidReceiveNotificationResponse = onDidReceiveNotificationResponse;
  _channel.setMethodCallHandler(_handleMethod);

  final Map<String, Object> arguments = initializationSettings.toMap();

  _evaluateBackgroundNotificationCallback(
      onDidReceiveBackgroundNotificationResponse, arguments);

  return await _channel.invokeMethod('initialize', arguments);
}