ios - 当应用程序在后台时 didReceiveRemoteNotification 不使用 Firebase 调用

标签 ios objective-c iphone firebase

使用 Firebase 我发送这个 JSON:

{
  "data": {
  },
  "priority": "high",
  "to": "xxxxx",
  "content-available": "true",
  "notification": {
    "body": "HI!",
    "title": "FCM Message",
    "badge": 1,
    "sound": "Default"
  }
}

但是 didReceiveRemoteNotification:fetchCompletionHandler 在应用程序处于后台时不会被调用。

我启用后台模式 - 来自功能的远程通知。

有什么建议吗?

最佳答案

您的 content-available 键/值不正确。键是 content_available(下划线,不是破折号),值是 bool 值,而不是字符串:

{
  "data": {
  },
  "priority": "high",
  "to": "xxxxx",
  "content_available": true,  // <= CHANGED
  "notification": {
    "body": "HI!",
    "title": "FCM Message",
    "badge": 1,
    "sound": "Default"
  }
}

参见 Table 1 of the HTTP Server Protocol document :

On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken. On Android, data messages wake the app by default. On Chrome, currently not supported.

关于ios - 当应用程序在后台时 didReceiveRemoteNotification 不使用 Firebase 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44724994/

相关文章:

ios - Realm 在更新时为嵌套对象创建多个条目

iphone - 如何将 bool 状态发布到 NSNotificationCenter?

ios 游戏 - GPU 端计算有什么缺点吗?

iphone - iPhone 5s 上未安装应用程序

ios - 表脚 View 按钮

使用 OpenGL ES 2.0 的 iOS 360 视频

ios - 如何打印来自简单有效的 POST 方法的响应

ios - Swift - 类型 '*' 不符合协议(protocol) '*'

objective-c - 如何对图像中的颜色进行采样

objective-c - UIBezierPath 多行颜色