[Bug]: Old Notification Displayed When Starting App
What happened?
An old notification is displayed when starting the app.
Steps to reproduce?
Login
Get a notification
Force stop the app
Launch it later
Old notification is displayed again
What did you expect to happen?
I expected not to see the old notification
OneSignal Android SDK version
5.1.2
Android version
13
Specific Android models
Android Emulator Pixel 3a on API 34
I'm pretty sure the fix is an easy one.
NotificationGenerationProcessor.kt line 57
Change if (!isRestoring && isDuplicateNotification(notification)) -> if (isRestoring || isDuplicateNotification(notification))
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@simon1867 thanks for reporting, we'll look into this more and get back to you as soon as possible.
Hello @simon1867 Could you please provide any updates on the status of this issue?
Hello @simon1867 Could you please provide any updates on the status of this issue?
Has there been a new release to address this?
@simon1867 I apologize, I meant to mention @jennantilla, but I accidentally mentioned you.
Hello @jennantilla Could you please provide any updates on the status of this issue?
@simon1867 @kishibata
This is expected restore behavior of the SDK, as the notification was not dismissed or opened by the end-user the notification is restored so it isn't lost. I'll explain in more detail below step-by-step:
- Get a notification - Displays as expected, SDK saves the data to disk
- Force stop the app - Android clears all notifications for the app here
- Launch it later - Android doesn't automatically put the notifications back.
- Old notification is displayed again - This is behavior the SDK is intently doing
The reason the SDK does this as the end-user may have not looked at their notifications on step 2, so they could have missed them. Since some notifications might be very old and no longer relevant the SDK checks the TTL before restoring them.
@jkasten2 It was mentioned that old notifications would not be displayed again by checking their TTL, but specifically, how much time needs to have passed since receiving the notification for it not to be displayed again?
@kishibata The SDK starts the TTL clock when it receives the push in this case. The TTL is 72 hours by default, but you can set that to a different value when sending the notification.