【问题标题】:Firebase send push notifications via curl command works, but not from firebase consoleFirebase 通过 curl 命令发送推送通知有效,但不是来自 firebase 控制台
【发布时间】:2018-10-20 12:55:33
【问题描述】:

我正在使用 swift 开发一个应用程序并尝试集成推送通知。

Firebase 通过 curl 命令发送推送通知有效,但不是从 firebase 控制台。

我遵循了不同教程的每一步,使用了 AuthKey,捆绑 ID 是正确的,我没有收到任何错误,推送通知的状态是“完成/完成”。

这是我正在使用的 curl 命令

curl --header "Content-Type: application/json" \
--header "Authorization: key="My Server Key"
https://fcm.googleapis.com/fcm/send \
-d '{"notification": {"body": "Hellof!", "sound": "default"},
"priority": "high",
"to": "FMC push token"}'

我希望有人能解决这个问题或类似的经历。

【问题讨论】:

  • Firebase 控制台上的内容是什么?
  • firebase 什么也没说。推送消息已完成,状态为“已完成”。没有错误或任何东西。就像说的那样,它确实适用于 curl 命令。
  • 我也面临同样的问题。 Push 适用于 CURL,但不适用于 Firebase 控制台。不适用于安卓和iOS。 :(

标签: firebase curl firebase-cloud-messaging firebase-console


【解决方案1】:

我也使用你给出的类似 JSON 结构让它在 curl 中工作。但在某些情况下,它会导致正文和标题为空值(我也使用了标题字段)

当我在 JSON 中使用“数据”而不是“通知”时变得更好

尝试更改 JSON,如下所示。我没有在您描述的确切上下文中自己尝试过(Firebase 控制台),但是当我使用 CURL 执行此操作时,我发现正文和标题都正确显示在通知中

curl --header "Content-Type: application/json" \
--header "Authorization: key="My Server Key"
https://fcm.googleapis.com/fcm/send \
-d '{"data": {"title": "The Title","body": "Hellof!", "sound": "default"},
"priority": "high",
"to": "FMC push token"}'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 2021-07-15
    • 2017-11-23
    • 2019-09-14
    • 1970-01-01
    • 2020-12-09
    相关资源
    最近更新 更多