Here is the picture of android push notification anatomy. No 3 in the picture is a timestamp indicating push notification relevance time (or respective event time) such as the time of a missed call.
I noticed that the format of the date&time value displaying in this field varies on different Android smartphones whereas the same app code is running on all of them.
For instance if our app notifies about an event took place yesterday (the 16th of January 2024) at 22:00 (GMT +7) we use a respective timestamp value ("1705417200000" in this example) being input in the .setWhen(timestamp).
Today morning (the 17th of January 2024) this date&time field of push notification (No 3 in the picture) on different Android smartphones can look like:
- "1d" (meaning 1 day ago),
- "14h" (meaning 14 hours ago),
- "22:00" (meaning event time = 22:00 of the previous day)
- "16/01/2024" (meaning just the day of the event date&time)
- etc
Can somebody help with any suggestions on how to manage this date&time displaying?
I tried to manage this by setting different priorities or categories to notifications in the notification builder expecting it could implicitly or indirectly impact the way time-sensitive push notifications are displayed:
The code snippet is as follows:
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.ic_notification)
.setShowWhen(true)
.setWhen(eventTime)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_HIGH);
However nothing new was happened in relation to date&time displaying.