node.js - “消息”中的未知名称“time_to_live”:
问题描述
我正在尝试通过 firebase 发送推送通知:
await admin.messaging().sendAll({
token: 'some token',
data: {val1: '1', val2: '2'},
time_to_live: 300,
});
我收到下一个错误:
{"message":"发送推送通知失败,收到无效的 JSON 有效负载。'message' 处的未知名称 "time_to_live": 找不到字段。","level":"error"}
解决方案
在 firebasetime_to_live
的 key 中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)
在 的情况下使用ttl
密钥time_to_live
。
推荐阅读
- linux - 如何在 debian linux 中获取 FTP 传输的 ISA06 交换发件人 ID
- postgresql - postgresql如何分组然后获取first_time和last_time,
- java - 避免工具提示抓住鼠标焦点
- python - 我如何对列表进行排序 python maya
- c++ - C++ 段错误有时但是
- corda - Corda 与 springboot 构建 JAR
- mysql - Innobyte 插件问题:SQLSTATE [23000]:完整性约束违规:1452 无法添加或更新子行
- c# - 我可以在 .NET 控制器上返回不同的剃须刀视图吗?
- performance - 多个单线程二进制文件比一个并行 OpenMP 进程更快?
- python - 使用“烧瓶运行”不会启用调试器....为什么?