FCM in android notification payload , event_time

563

Zulu is not a time format. It's a time zone. Zulu is just another name for UTC.

As per this article:

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

Now, about the timestamp value. If you are creating a Date object and use milliseconds or nanoseconds property of a date, it will always give you the difference in respective property type (mills/nano),

From the time you created the instance and starting time of UNIX which is 1 January 1970.

It has been 50 years as of 1st Jan, 2020. Hence the 50 year difference in the event_time.

If you have any other doubts let me know.

Share:
563
Epool Ranggi
Author by

Epool Ranggi

Updated on December 16, 2022

Comments

  • Epool Ranggi
    Epool Ranggi over 1 year

    i want to make the notification push on like maybe 5 minute after i run this http function. delete the event_time from the jsaon of notification i will receive the push notification that have timeline now, but if i hard code the event_time the time will show 50 year ago since epoch time , event i put 999 for the year it just increase by 2 year . i dint get it at all. then found Timestapm format in google and firebase so use it and the android got error whil parsing the json payload said cant fine field something . have any idea to format the Zulu RC399 time format?

    
    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();
    
    
      });