Fix notification timestamp to use original send time (#1112)

When notifications were delayed (e.g., due to lack of internet), Android
notifications showed the current time instead of the original message
timestamp. Added setWhen() and setShowWhen() to NotificationCompat.Builder.
This commit is contained in:
Philipp Heckel 2026-02-03 18:36:51 -05:00
parent f4d4c2aec4
commit 6c4f5e8810
2 changed files with 3 additions and 0 deletions

View file

@ -90,6 +90,8 @@ class NotificationService(val context: Context) {
.setSmallIcon(R.drawable.ic_notification)
.setColor(Colors.notificationIcon(context))
.setContentTitle(title)
.setWhen(notification.timestamp * 1000) // Set timestamp (convert seconds to millis)
.setShowWhen(true)
.setOnlyAlertOnce(true) // Do not vibrate or play sound if already showing (updates!)
.setAutoCancel(true) // Cancel when notification is clicked
setStyleAndText(builder, subscription, notification) // Preview picture or big text style

View file

@ -5,3 +5,4 @@ Features:
Bug fixes + maintenance:
* Fix crash when URL scheme is missing in default server (#1582, ntfy-android#158, thanks to @hard-zero1 for reporting)
* Fix notification timestamp to use original send time instead of receive time (#1112, thanks to @voruti for reporting)