get_timestamp function from the framework returns time in seconds since epoch and it also doesn't consider time for the datetime object - uses getdate internally so not very reliable
After I calculated & passed the milliseconds since the epoch, android showed (in 5 hrs). Epoch being timezone unaware, the OS seemed to be converting the timestamp to the user timezone somehow (guessing because IST is UTC + 5:30)
So tried converting system datetime to UTC and this seems to be reflecting correctly.
Most of this is not explicitly documented. Maybe the push client in the framework should handle this (not relay because we need access to the system timezone) when the app passes a timestamp. A mismatch in framework & raven versions might cause issues so resorted to a fix here. Will add support to the core client too. Thoughts?
Note to reviewer: Retest on both devices again probably
Problem:
The
showNotification
API expects the timestamp to be provided in milliseconds since the epoch Ref: https://web.dev/articles/push-notifications-display-a-notification#timestamp But Raven was sending this in seconds.get_timestamp
function from the framework returns time in seconds since epoch and it also doesn't consider time for the datetime object - usesgetdate
internally so not very reliableAfter I calculated & passed the milliseconds since the epoch, android showed (in 5 hrs). Epoch being timezone unaware, the OS seemed to be converting the timestamp to the user timezone somehow (guessing because IST is UTC + 5:30)
So tried converting system datetime to UTC and this seems to be reflecting correctly.
These changes don't seem to affect iOS. Looks like it doesn't support timestamp overriding. Just picks up the time when the message was delivered. https://developer.mozilla.org/en-US/docs/Web/API/Notification/timestamp
Screenshots
**Before**:Most of this is not explicitly documented. Maybe the push client in the framework should handle this (not relay because we need access to the system timezone) when the app passes a timestamp. A mismatch in framework & raven versions might cause issues so resorted to a fix here. Will add support to the core client too. Thoughts?
Note to reviewer: Retest on both devices again probably
Closes https://github.com/The-Commit-Company/Raven/issues/874