initialize static method
Implementation
static Future<void> initialize({
required GlobalKey<NavigatorState> navigatorKey,
String? androidNotificationIcon,
}) async {
_navigatorKey = navigatorKey;
_androidNotificationIcon = androidNotificationIcon;
await requestNotificationPermission();
final androidInit = AndroidInitializationSettings(
_androidNotificationIcon ?? '@mipmap/ic_launcher');
const iosInit = DarwinInitializationSettings();
final initSettings = InitializationSettings(
android: androidInit,
iOS: iosInit,
);
await _notificationsPlugin.initialize(
initSettings,
onDidReceiveNotificationResponse: (NotificationResponse response) {
_handlePayload(response.payload);
},
onDidReceiveBackgroundNotificationResponse: _notificationTapBackground,
);
final launchDetails =
await _notificationsPlugin.getNotificationAppLaunchDetails();
if (launchDetails?.didNotificationLaunchApp ?? false) {
_pendingPayload = launchDetails!.notificationResponse?.payload;
}
}