node.js - 带有nodejs的FCM未向模拟器发送通知
问题描述
我试图使用 firebase admin 向我的所有设备发送通知,但它不起作用
import admin from 'firebase-admin';
var serviceAccount = require('./firebase.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
var condition = "!('stock-GOOG' in topics)";
// See documentation on defining a message payload.
var message = {
data: {
title: 'asdasdas',
},
notification: {
title: '$FooCorp up 1.43% on the day',
body:
'$FooCorp gained 11.80 points to close at 835.67, up 1.43% on the day.',
},
condition: condition,
};
// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
admin
.messaging()
.send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
尽管它让我知道消息已正确发送,但我的模拟器上没有任何内容出现在我正在使用它进行测试的情况下。当我尝试从控制台发送通知时,一切正常。
解决方案
推荐阅读
- sql - Spark Scala比较2个数据帧的行和行并获得差异
- html - 使用 rvest 获取其中的 href 的网络抓取表返回空表
- sqlite - 在我的手机上找不到 SQLite 数据库 (db3) 文件
- python - 存储数字在-255和255之间的numpy数组的最小方法?
- bootstrap-4 - 如何使 Bootstrap 4 汉堡菜单工作?
- c++ - 关于 C++ 中数据结构的迭代器和指针的问题
- jquery - 如何使用 jquery 切换到下一个父行?
- curve-fitting - 通过线性方程 y = mx 的原点进行曲线拟合
- python - 仅在开始日期和结束日期之间按标识符对两列求和
- fortran - Fortran Preprocessor Macro with Newline