0

I am using the local notification package and I need to add buttons to notification. How to add these buttons to a notification.

Future<void> showDailyAtTime() async {
    var time = Time(20, 3, 0);
    var androidChannelSpecifics = AndroidNotificationDetails(
      'CHANNEL_ID 4',
      'CHANNEL_NAME 4',
      "CHANNEL_DESCRIPTION 4",
      importance: Importance.Max,
      priority: Priority.High,
    );
    var iosChannelSpecifics = IOSNotificationDetails();
    var platformChannelSpecifics =
    NotificationDetails(androidChannelSpecifics, iosChannelSpecifics);
    await flutterLocalNotificationsPlugin.showDailyAtTime(
      0,
      'Test Title at ${time.hour}:${time.minute}.${time.second}',
      'Test Body', //null
      time,
      platformChannelSpecifics,
      payload: 'Test Payload',
    );
  }

this is the function which iam using to show notification

OMi Shah
  • 5,768
  • 3
  • 25
  • 34
  • Does this answer your question? [Flutter: How Can I Add buttons to Local Notification](https://stackoverflow.com/questions/52408222/flutter-how-can-i-add-buttons-to-local-notification) – Rusu Dinu Jul 18 '21 at 06:49
  • yes, I want to like this pic in this question, but I can't use this code with my code. actually, i can't understand this code – Abdelrahman Bahig Jul 18 '21 at 06:57
  • I think he creates something like local notification from first – Abdelrahman Bahig Jul 18 '21 at 06:59
  • Yes, he's using LocalNotifications to create and show the notification, the 'actions' list represents the buttons that are displayed in the notification, those buttons will have the text 'First' and 'Second' and they also have ids 'firstAction', and 'secondAction' in order to differentiate them when the user clicks on one of the buttons, and the function 'handleCustomActionClick' is called (you can see that it is set as a callback). – Rusu Dinu Jul 18 '21 at 07:02
  • how to add this in my code. if i put this code gives me error because he use localNotifications as a class not package as i use – Abdelrahman Bahig Jul 18 '21 at 08:40
  • by this way i should delete what is done ? and create the new project with this code? – Abdelrahman Bahig Jul 18 '21 at 08:56

0 Answers0