【问题标题】:Why does not receive FCM notifications on IOS when the app is in background and receive in foreground? Flutter为什么应用在后台和前台接收时,在 IOS 上收不到 FCM 通知?扑
【发布时间】:2021-04-14 09:48:48
【问题描述】:

我有一个 Flutter 应用,它会在某个时刻向所有用户发送 Firebase 通知。它在 android 上运行良好,但在 iOS 中只能在应用程序打开的情况下运行。如果我关闭应用程序(例如转到主屏幕),它没有收到任何信息。

我已经设置了 'priority' : 'high', "content_available" : true 但仍然无法正常工作。我可以做些什么来执行它?

如果您需要一些代码/信息,我会更新问题。

更新:是的,我正在使用 onResume

    _firebaseMessaging.configure(

      onMessage: (Map<String, dynamic> message) async {
        print("onMessage: ${message}");
        print(message['notification']['body']);

      },

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

【问题讨论】:

    标签: ios swift flutter push-notification firebase-cloud-messaging


    【解决方案1】:

    您是否在配置中使用 onResume?
    您需要添加它。看看吧

    【讨论】:

    • 我不确定,但问题可能是您正在使用打印方法,当您的程序在后台时它不会显示在控制台上,而是查看 logcat
    • 但在android中完美运行,我不认为这是问题
    • 哦,我明白了,然后是 nvm
    猜你喜欢
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 2020-06-21
    • 2022-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多