-1

我的代码如下。它在 Android 设备上运行良好,但是当我单击通知时,它不会在 IOS 上打开特定屏幕。它只是打开应用程序。我希望它打开特定的屏幕。

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

它适用于 Android 设备。我应该怎么办?提前致谢...

4

1 回答 1

1

您可以在应用程序启动时使用此代码来提供通知的有效负载或导致打开应用程序并进行导航或我们想做的所有其他工作的详细信息:

var details = await FlutterLocalNotificationsPlugin().getNotificationAppLaunchDetails();
if (details.didNotificationLaunchApp) {
 await Navigator.push(
    context,
    MaterialPageRoute(builder: (context) => SpesificScreen())
 ); 
}
于 2021-11-25T11:07:30.230 回答