Flutter:当应用程序处于后台但未在 iOS 中终止时,无法在通知单击时重定向到特定屏幕

Flutter : Unable to redirect to specific screen on Notification click when app is in background but not terminated in iOS

我使用了 firebase_messaging 通知插件,在两个平台上通知都工作正常,

但是,我想在通知点击事件中将用户重定向到特定屏幕。对于 Android 端,它工作正常。但对于 IOS,如果应用程序在后台且未终止,则它不起作用(如果应用程序终止,则工作正常)。

这是我的通知集成代码示例:

_firebaseMessaging.configure(
  onMessage: (Map<String, dynamic> message) async {
    print("onMessage: $message");
    gotoTempPage();
  },
  onLaunch: (Map<String, dynamic> message) async {
    print("onLaunch: $message");
    gotoTempPage();
  },
  onResume: (Map<String, dynamic> message) async {
    print("onResume: $message");
    gotoTempPage();
  },
);

我正在使用插件版本 firebase_messaging: ^6.0.9,以及 flutter 版本 v1.12.13+hotfix.5

已经提到了这些问题 935, 1757, 1677 但没有任何帮助。

您好,我遇到了完全相同的问题。因此,根据插件的当前文档 (firebase_messaging),您应该对 Appdelegate.m/Appdelegate.swift 文件进行一些修改。

这个修改就是问题所在

AppDelegate.swiftAppDelegate.m

中的类似代码中删除以下代码
if #available(iOS 10.0, *) {
          UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}

这似乎是此版本 firebase_messaging (6.0.9) 的错误或问题,如 here