iOS 中的 FirebaseMessaging.onBackgroundMessage 当应用程序终止/后台从未调用

发布于 2025-01-12 00:57:40 字数 1139 浏览 4 评论 0原文

我有这个问题,我有一个处理程序传递给 FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler) ,该处理程序负责将传入通知记录保存到 SQFLite 数据库中,并通过调用以大图像显示传入通知:

flutterLocalNotificationsPlugin.show()

但是,在 iOS 中运行应用程序时当应用程序处于后台或终止时,通知会按预期显示,但 onBackgroundMessage 不会被调用,我知道它不会被调用,因为与通知相关的记录没有被保存到SQFLite数据库和大图像都出现在通知中,但通知的标题和正文显示正确, 请指教, 注意:我使用 Firebase Cloud Messaging 发送的负载如下:

{
 "to": "My-Device-Token",
 "notification": {
                   "Type": "Price_Inquiry",
                   "title": "Price Inquiry Reply",
                   "body": "Item #R45 Price",
                   "Image": "URL_To_Big_Image",
                   "ID": 1960,
                   "Recipient": "Recipient Name"
                 },
 "data": {
          "title": "Price Inquiry Reply",
          "body": "Item #R45 Price",
          "image": "URL_To_Big_Image",
          "email": "[email protected]",
          "type": "Price_Inquiry",
          "id": 1960
          }
}

非常感谢您的帮助, 提前致谢,

I have this issue, that I have a handler passed to FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler) that's responsible to save the incoming notification record into SQFLite database and to show the incoming notification with a Big Image by calling:

flutterLocalNotificationsPlugin.show()

However, when running the app in iOS and when app is in background or terminated, then the notification appears as expected, but the onBackgroundMessage doesn't get called, I know it's not being called because the notification related record is not being saved into SQFLite database nor the Big Image appear in the notification, but the title and body of the notification are displayed correctly,
Please advise,
Note: The payload I'm sending with Firebase Cloud Messaging is as follows:

{
 "to": "My-Device-Token",
 "notification": {
                   "Type": "Price_Inquiry",
                   "title": "Price Inquiry Reply",
                   "body": "Item #R45 Price",
                   "Image": "URL_To_Big_Image",
                   "ID": 1960,
                   "Recipient": "Recipient Name"
                 },
 "data": {
          "title": "Price Inquiry Reply",
          "body": "Item #R45 Price",
          "image": "URL_To_Big_Image",
          "email": "[email protected]",
          "type": "Price_Inquiry",
          "id": 1960
          }
}

Your help is highly appreciated,
Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文