gpt4 book ai didi

iOS 10 Firebase 通知未在后台显示

转载 作者:可可西里 更新时间:2023-11-01 05:50:01 25 4
gpt4 key购买 nike

我在运行 iOS 10 的特定设备上接收推送通知(后台)时遇到问题。其他运行 iOS 9 的手机运行良好。

虽然如果我打开应用程序,通知会显示我实现的横幅。为什么在后台状态下不显示任何内容?

阅读 firebase 文档让我有些困惑

根据以下链接上的 github firebase 示例 https://github.com/firebase/quickstart-ios/blob/master/messaging/FCMSwift/AppDelegate.swift ,在 didReceiveRemoteNotification 方法中有一条评论说:

// If you are receiving a notification message while your app is in the background, // this callback will not be fired till the user taps on the notification launching the application. // TODO: Handle data of notification

所以如果我的应用程序在后台,苹果不会做所有事情来发出默认的 iOS 通知吗? content_available 值是否会对此产生干扰?我还发送通知和数据值。

这是我发送的 JSON 示例:

{
"content_available": true,
"priority": "high",
"data": {
"post_id": "...",
"push_id": "..."
},
"notification": {
"title": "...",
"body": "..."
},
"registration_ids": ["xxxx"]
}

预期的行为是:

  1. 应用死机:系统会显示通知
  2. 应用后台:系统会显示通知并调用didReceiveRemoteNotification方法。
  3. 应用激活:系统不会显示通知并调用 didReceiveRemoteNotification 方法。

对吧?

最佳答案

除了数字 2 之外,您的假设都是正确的。有几种情况,即使您设置了 content_avaialable,苹果也不会调用 didReceiveRemoteNotification。

1) 设备电量低,处于省电模式

2) 应用已禁用“后台应用刷新”

3) 苹果决定不唤醒您的应用程序的其他未记录的场景。 Apple 保留出于性能原因不发送通知的权利。

话虽如此,如果用户点击通知,您将始终在 didReceiveRemoteNotification 中获得有效负载。

关于iOS 10 Firebase 通知未在后台显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39733841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com