简体   繁体   English

Flutter 本地通知在 IOS 上未按预期工作

[英]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.它在 Android 设备上运行良好,但是当我单击通知时,它不会在 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.它适用于 Android 设备。 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())
 ); 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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