Reputation: 21
class HelperNotification {
static Future<void> initialize(FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin) async {
var androidInitialize = new AndroidInitializationSettings('notification_icon');
var iOSInitialize = new DarwinInitializationSettings();
var initializationsSettings = new InitializationSettings(android: androidInitialize, iOS: iOSInitialize);
flutterLocalNotificationsPlugin.initialize(initializationsSettings, onSelectNotification:(String? payload) async {
try{
if(payload != null && payload.isNotEmpty) {
// Get.toNamed(RouteHelper.getOrderDetailsRoute(int.parse(payload)));
}else {
// Get.toNamed(RouteHelper.getNotificationRoute());
}
}catch (e) {}
return;
});
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
I found that there was an update with the local notification package but i was trying to implement it and was unsuccessful can you help me figure it out?
Upvotes: 1
Views: 539
Reputation: 36323
Since version 10.0.0 of the flutter_local_notifications
plugin, they removed onSelectNotification
parameter. You can read more about it in their changelog:
Breaking change callbacks have now been reworked. There are now the following callbacks and both will pass an instance of the NotificationResponse class onDidReceiveNotificationResponse: invoked only when the app is running. This works for when a user has selected a notification or notification action. This replaces the
onSelectNotification
callback that existed before. For notification actions, the action needs to be configured to indicate the the app or user interface should be shown on invoking the action for this callback to be invoked i.e. by specifying the DarwinNotificationActionOption.foreground option on iOS and the showsUserInterface property on Android. On macOS and Linux, as there's no support for background isolates it will always invoke this callback onDidReceiveBackgroundNotificationResponse: invoked on a background isolate for when a user has selected a notification action. This replaces the onSelectNotificationAction callback
Read more here: https://pub.dev/packages/flutter_local_notifications/changelog
Upvotes: 2