OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

[Bug]: Old Notification Displayed When Starting App

Open simon1867 opened this issue 2 years ago • 6 comments

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 avatar Feb 01 '24 17:02 simon1867

@simon1867 thanks for reporting, we'll look into this more and get back to you as soon as possible.

jennantilla avatar Feb 02 '24 23:02 jennantilla

Hello @simon1867 Could you please provide any updates on the status of this issue?

kishibata avatar Mar 27 '24 02:03 kishibata

Hello @simon1867 Could you please provide any updates on the status of this issue?

Has there been a new release to address this?

simon1867 avatar Mar 27 '24 14:03 simon1867

@simon1867 I apologize, I meant to mention @jennantilla, but I accidentally mentioned you.

kishibata avatar Apr 04 '24 01:04 kishibata

Hello @jennantilla Could you please provide any updates on the status of this issue?

kishibata avatar Apr 04 '24 01:04 kishibata

@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:

  1. Get a notification - Displays as expected, SDK saves the data to disk
  2. Force stop the app - Android clears all notifications for the app here
  3. Launch it later - Android doesn't automatically put the notifications back.
  4. 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 avatar Jun 24 '24 17:06 jkasten2

@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 avatar Jul 10 '24 07:07 kishibata

@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.

jkasten2 avatar Jul 10 '24 17:07 jkasten2