flutter_local_notifications
flutter_local_notifications copied to clipboard
onSelectNotification is removed on localNotifications.initialize?
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);
});
}
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);
}
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