【问题标题】:Parsing data messages with Firebase Cloud Messaging with Flutter and Firebase on an iOS device在 iOS 设备上使用 Flutter 和 Firebase 使用 Firebase Cloud Messaging 解析数据消息
【发布时间】:2018-09-24 06:19:09
【问题描述】:

我不确定如何在iOS 上使用FCMFlutter 接收数据消息。

为了让您快速了解我的立场,我可以在我的iOS 设备上接收push notifications。所以我已经正确配置了一切(或者我相信)。

因此,当应用程序在后台运行时,我会在通知托盘中收到通知。

当应用程序在前台时,我也在 onMessage 回调中收到消息。

但是,当我尝试通过HTTPhttps://fcm.googleapis.com/fcm/send 请求模拟数据消息并发送正文时:

{
 "to" : MY_FIREBASE_TOKEN,
 "collapse_key" : "type_a",
 "data" : {
   "firstKey" : "firstValue",
   "secondKey": "secondValue"
   }
}

它根本没有出现在我的 onMessage 上。

我在Xcode 项目功能上启用了推送通知。

我还在同一个Xcode 项目功能选项卡中启用了Background Modes 中的Remote Notifications

我不确定我错过了哪一部分,因为我根本无法接收数据消息。

我也尝试过模拟向dart plugin page中的示例项目发送数据消息,但无济于事。

【问题讨论】:

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


    【解决方案1】:

    来自 iOS 的插件 README

    消息由 FCM 存储,并在应用返回前台时通过 onMessage 传递给应用。

    如果它不起作用,您应该向 github repo https://github.com/flutter/plugins/tree/master/packages/firebase_messaging提交问题

    【讨论】:

    • 我明白了,但是当应用程序已经在前台并通过 HTTP 请求接收数据消息时,它不应该显示在 onMessage 块中吗?
    • 我猜这是插件中的错误或未实现的东西抱歉:/
    猜你喜欢
    • 2016-09-22
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    • 2020-08-19
    • 2020-04-26
    相关资源
    最近更新 更多