import 'package:flutter_local_notifications/flutter_local_notifications.dart'; class NotificationHelper { FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); Future initialize() async { final initializationSettingsAndroid = AndroidInitializationSettings('app_icon'); final initializationSettings = InitializationSettings( android: initializationSettingsAndroid, ); // await flutterLocalNotificationsPlugin.initialize( // initializationSettings, // onSelectNotification: onSelectNotification, // ); await flutterLocalNotificationsPlugin.initialize( initializationSettings, onDidReceiveNotificationResponse: onDidReceiveNotificationResponse, ); } Future showNotification(int id, String title, String body) async { const AndroidNotificationDetails androidPlatformChannelSpecifics = AndroidNotificationDetails('your channel id', 'your channel name', // 'your channel description', importance: Importance.max, priority: Priority.high); const NotificationDetails platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show( id, title, body, platformChannelSpecifics, ); } // Future onDidReceiveNotificationResponse(String? payload) async { // if (payload != null) { // print('Notification payload: $payload'); // } // } Future onDidReceiveNotificationResponse( NotificationResponse response) async { // Lakukan sesuatu berdasarkan respons pengguna terhadap pemberitahuan // Misalnya, buka layar tertentu atau jalankan tindakan tertentu print('Notification tapped! Payload: ${response.payload}'); } Future onDidReceiveLocalNotification( int id, String title, String body, String payload) async { // Callback when a local notification is received while the app is in the foreground } }