在MySQL DB中存储通知详细信息(使用FCM推送通知)
我正在node.js和express中编写服务器。 我正在通过Firebase通知发送给我的应用程序用户通知,然后将其发送给用户,我想在MySQL DB 中存储我的通知详细信息。
我在存储通知详细信息时有一个问题,它不起作用(行不确定,并且在db表中没有数据添加数据)。
这是我的相关代码:
const message_notification = {
notification: {
title: "notification_title",
body: "notification_body"
}
};
const notification_options = {
priority: "high",
timeToLive: 60 * 60 * 24
};
admin.messaging().sendToDevice(device_token, message_notification, notification_options)
.then( response => {
//doesn't work
mySqlConnection.query(`insert into notifications (notification_id, body, title) values
(?,?,?)`, [response.multicastId, message_notification.notification.body, message_notification.notification.title], (err,rows)=>
{
try
{
console.log(rows);
}
catch(err)
{
console.log(err)
}
});
})
I'm writing a server in Node.js and express.
I'm sending to my app users push notifications via firebase notifications, and after I send it to the user, I want to store my notification details in MySql DB.
I have a problem in storing the notification details, it doesn't work (rows is undefined and no data is added to the DB table).
This is my relevant code:
const message_notification = {
notification: {
title: "notification_title",
body: "notification_body"
}
};
const notification_options = {
priority: "high",
timeToLive: 60 * 60 * 24
};
admin.messaging().sendToDevice(device_token, message_notification, notification_options)
.then( response => {
//doesn't work
mySqlConnection.query(`insert into notifications (notification_id, body, title) values
(?,?,?)`, [response.multicastId, message_notification.notification.body, message_notification.notification.title], (err,rows)=>
{
try
{
console.log(rows);
}
catch(err)
{
console.log(err)
}
});
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论