node.js - 使用 Firebase Admin SDK 发送带有图像负载的推送通知
问题描述
我正在尝试通过firebase admin sdk发送推送通知,但图像以某种方式未显示在推送通知中。
奇怪的是,当我在通知对象中使用无效键(如image
)时,我得到一个错误。所以我假设我指定了正确的键。可以在此处找到通知文档。
以下代码成功发送推送通知,但用户手机上没有显示图像:
const admin = require('firebase-admin');
const app = admin.initializeApp({...}); // authenticated with credentials json file
await app.messaging().sendMulticast({
notification: {
title: "hello User",
body: "This is a push notification with an image",
imageUrl: "https://example.com/myPublicImage.png",
},
tokens: ["device_token_1", "device_token_2","..."]
});
解决方案
推荐阅读
- vbscript - Vbscript 无法读取某些子键?
- azure-devops - 将 repo 动态检出到固定目录中
- r - 如何将复制的字符串保存在R中原子向量中用逗号分隔的多行中?
- python - 在 Tensorflow 中实现自定义损失函数时出现错误 Input tensor must be at least 2D: [] [Op:BiasAddGrad]
- javascript - 将 API 响应中的数据保存到使用它的应用脚本
- google-cloud-platform - VCP Google Cloud Platform 的 Dataflow Pub/Sub 主题到 BigQuery 未从订阅中提取数据
- python - tsne Mac 的构建轮失败
- azure - Azure 应用服务 - url 参数中带有斜线的 REST API
- c++ - 使用 LuaBridge 的模板函数内部的“addConstructor”出现奇怪的编译器错误
- javascript - 如果参数为负,我如何返回错误?