Reputation: 93
My codes are below. It is working very well on Android devices but when I click the notification, it doesn't open specific screen on IOS. It just opens the app. I want it open the spesific screen.
Future<void> initSettings() async {
var initAndorid = AndroidInitializationSettings('my_logo');
var initIOS = IOSInitializationSettings(
requestSoundPermission: false,
requestBadgePermission: false,
requestAlertPermission: false,
);
var initSetting =InitializationSettings(android: initAndorid, iOS: initIOS);
notificationsPlugin = new FlutterLocalNotificationsPlugin();
await notificationsPlugin.initialize(initSetting,
onSelectNotification: notificationSelected);
}
Future notificationSelected(String? payload) async {
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => SpesificScreen())
);
}
It's working on Android devices. What should I do? Thanks in advance...
Upvotes: 2
Views: 1243
Reputation: 983
You can use this code on your app startup to give notification's payload or details that cause to open app and do navigate or every other work we want to do :
var details = await FlutterLocalNotificationsPlugin().getNotificationAppLaunchDetails();
if (details.didNotificationLaunchApp) {
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => SpesificScreen())
);
}
Upvotes: 1