init method
Implementation
void init(PushClickAction onClickNotificationFunction) async {
onClickNotification = onClickNotificationFunction;
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
final IOSInitializationSettings initializationSettingsIOS =
IOSInitializationSettings(onDidReceiveLocalNotification:
(int id, String? title, String? body, String? payload) {
onSelectNotification(payload);
});
final InitializationSettings initializationSettings =
InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS,
);
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: (String? payload) {
onSelectNotification(payload);
});
}