flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

onSelectNotification is removed on localNotifications.initialize?

Open winterwind999 opened this issue 1 year ago • 1 comments

i'm following this tutorial to set up a push notification and at 12:53 she uses onSelectNotification, however, onSelectNotification is not in initialize anymore? what should i do

Future initLocalNotifications() async {
    const iOS = DarwinInitializationSettings();
    const android = AndroidInitializationSettings('@drawable/ic_launcher');
    const settings = InitializationSettings(android: android, iOS: iOS);

    await _localNotifications.initialize(settings,
        onSelectNotification: (payload) {
      final message = RemoteMessage.fromMap(jsonDecode(payload));
      handleMessage(message);
    });
  }

winterwind999 avatar Oct 09 '24 20:10 winterwind999

Did you try to use onDidReceiveNotificationResponse?

/// The [onDidReceiveNotificationResponse] callback is fired when the user
/// selects a notification or notification action that should show the
/// application/user interface.

onDidReceiveNotificationResponse: (NotificationResponse notificationResponse) {
  final message = RemoteMessage.fromMap(jsonDecode(notificationResponse.payload));
  handleMessage(message);
}

iamongit avatar Oct 15 '24 18:10 iamongit

Closing as @iamongit has already answered this. For future reference, whenever you check tutorials and what not, be aware that whatever is mentioned there may be out of date and you should check the available docs on (breaking) changes/updates

MaikuB avatar Nov 29 '24 03:11 MaikuB