简体   繁体   中英

Flutter local notification is not working as expected on IOS

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...

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())
 ); 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM