【问题标题】:Unknown name "time_to_live" at 'message':“消息”中的未知名称“time_to_live”:
【发布时间】:2021-07-19 19:11:20
【问题描述】:

我正在尝试通过 firebase 发送推送通知:

await admin.messaging().sendAll({
token: 'some token',
data: {val1: '1', val2: '2'},
time_to_live: 300,
});

我收到下一个错误:

{"message":"发送推送通知失败,无效的 JSON 负载 已收到。 “消息”中的未知名称“time_to_live”:找不到 字段。","级别":"错误"}

【问题讨论】:

  • 您好,您可以提供您正在使用的确切 API 方法的参考吗?这是 Admin SDK 的一部分吗?

标签: node.js firebase firebase-cloud-messaging firebase-admin


【解决方案1】:

time_to_live 的firebase 中,密钥是ttl,我也使用此请求正文在Android 应用程序中发送推送通知:

const body = {
  notification: {
    title: 'xxxx',
    body: "xxxxxxxx"
  },
  data: {
    notification_message: "xxxxxx"
  },
  token: 'xxxxxx',
  android: {
    ttl: 3600,
    notification: { icon: 'xxxxx', color: '#b2b2b2' }
  }
}

await admin.messaging().send(body)

time_to_live 的情况下使用ttl 键。

【讨论】:

  • IOS呢?
  • 对不起,我不知道 iOS,如果我们可以在 iOS 上使用 firebase。我使用 apn 用于 ios 而不是 firebase。
猜你喜欢
  • 1970-01-01
  • 2021-07-30
  • 2017-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-05
  • 2015-11-12
  • 2023-03-28
相关资源
最近更新 更多