gpt4 book ai didi

android - Android通知负载中的FCM,event_time

转载 作者:行者123 更新时间:2023-12-03 12:19:40 31 4
gpt4 key购买 nike

我想在运行此 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();


});

最佳答案

Zulu 不是时间格式。这是一个时区。 Zulu 只是 UTC 的另一个名称。

根据这个article :

Another name for UTC Time is "Zulu" or "Z Time."

现在,关于时间戳值。如果您正在创建 Date 对象并使用日期的 millisecondsnanoseconds 属性,它将始终为您提供各自属性类型(mills/nano)的差异,

从您创建实例和 starting time of UNIX 开始即 1970 年 1 月 1 日

截至 2020 年 1 月 1 日,已经 50 年。因此 event_time50 年的差异。

如果您有任何其他疑问,请告诉我。

关于android - Android通知负载中的FCM,event_time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59560153/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com