initializeLocalNotification static method
dynamic
initializeLocalNotification({
- OnNotificationPressed? onNotificationPressed,
- required String icon,
Implementation
static initializeLocalNotification(
{OnNotificationPressed? onNotificationPressed,
required String icon}) async {
onPressed = onNotificationPressed;
// Create an Android notification Channel.
///
/// We use this channel in the `AndroidManifest.xml` file to override the
/// default FCM channel to enable heads up notifications.
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings(icon);
final DarwinInitializationSettings initializationSettingsIOS =
DarwinInitializationSettings();
final InitializationSettings initializationSettings =
InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS);
flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveNotificationResponse: notificationTapBackground,
onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
);
}