init method
void
init()
Load platform specific settings
Define NotificationResponse
actions
Implementation
void init() async {
await notifsPlugin.initialize(
appInitSettings,
onDidReceiveNotificationResponse: notifAction,
onDidReceiveBackgroundNotificationResponse: backgroundNotifAction,
);
// Request permissions //
await notifsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestPermission();
await notifsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
critical: false,
);
final NotificationAppLaunchDetails? notificationAppLaunchDetails =
await notifsPlugin.getNotificationAppLaunchDetails();
if (notificationAppLaunchDetails?.didNotificationLaunchApp == true &&
notificationAppLaunchDetails?.notificationResponse != null) {
backgroundNotifAction(notificationAppLaunchDetails!
.notificationResponse!); // handle / navigate
}
}