【发布时间】:2020-04-20 22:19:48
【问题描述】:
我想在我运行这个 http 函数 5 分钟后推送通知。从通知的 jsaon 中删除 event_time 我将收到现在有时间线的推送通知,但如果我硬编码 event_time 时间将显示自纪元时间以来的 50 年前,事件我将 999 放在这一年增加 2 年。我一点也不明白。然后在 google 和 firebase 中找到 Timestapm 格式,因此使用它,并且 android 在解析 json 有效负载时出错,说不能很好地处理某些内容。有任何想法格式化 Zulu RC399 时间格式吗?
pp.get('/sendCloudMessageReminderActivation', async (req, res) => {
const x = req.query.userUID;
const xstr = String(x);
const zxcv = admin.firestore().collection('user').doc(xstr);
const xoxo = await zxcv.get();
var today = new Date();
// today.setHours(today.getHours()+1);
today.setHours(today.getHours()+8);
// today.setFullYear(today.getFullYear()+50);
var xoxocode;
console.log(today+'saya saya sebelum cagbge');
// today = ISODateString(today);
const timestamp = admin.firestore.Timestamp.fromDate(today);
console.log(timestamp.nanoseconds +'siniiiiiiiiiiiiiiiiiiiii');
if (xoxo!==null) {
xoxocode= await xoxo.data().cloudMessagingToken;
const message = {
notification: {
title: 'your account is still in active state',
body: 'Tap here to check it out!'
},
android:{
priority:'high',
// important : 'MAX',
notification:{
notification_priority: "PRIORITY_MAX",
event_time: timestamp,// when ever i cahnge this event use ZULU RC339 format i still give my 50 year ago notification. i did my research but cant figure out how to do this ,
default_sound: true,
// notification_priority: PRIORITY_MAX
}
},
token: xoxocode
};
// res.status(200).send('authorized');
const respondfrommesage = admin.messaging().send(message);
console.log(respondfrommesage);
res.status(200).send('message send notification');
}
res.end();
});
【问题讨论】:
-
你解决问题了吗?
-
不,我没有,我取消了这个功能,因为它只是我的 FYP 项目,我的时间有限,但将来会使用这个 FMC 功能。
-
我向 Firebase 报告了这个问题,他们复制了它并计划修复它,但他们无法为此提供任何时间表。
标签: android node.js firebase flutter google-cloud-functions