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

[Bug]: preventDefault not working as expected if app relaunch within 30s

Open Harris-Cww opened this issue 1 year ago • 7 comments

What happened?

preventDefault doesn't prevent notification from reappear if user relaunch within 30 sec since NotificationGenerationProcessor.doWork() has a 30 sec window to wait if preventDefault is called before actually calling markNotificationAsDismissed() to mark the notification as shown.

Steps to reproduce?

1. open app then receive a notification in INotificationServiceExtension
2. call preventDefault to stop OS notification from being shown and do custom handling
3. relaunch app within 30s
4. onNotificationReceived() is triggered again with previous notification

What did you expect to happen?

preventDefault should mark the notification as shown immediately and will not show again after app relaunch

OneSignal Android SDK version

release 5.0.4

Android version

13

Specific Android models

Pixel 4 XL, Android 13
Pixel 6 Pro, Android 14
Huawei P50 Pro, EMUI 12.0.1

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Harris-Cww avatar Nov 23 '23 03:11 Harris-Cww

@Harris-Cww thanks for reaching out! We're working on reproducing this and will get back to you as soon as possible.

jennantilla avatar Nov 28 '23 19:11 jennantilla

any update on this issue? I'm currently saving the notification id and compare it every time i receive push notification again, which is kinda troublesome. hope to have some better solution, thanks

Harris-Cww avatar Dec 11 '23 07:12 Harris-Cww

@jennantilla This issue can be regenerated when preventDefault is called from a fragment. I cannot find a solution for this. The preventDefault does not show the issue when used inside a activity.

Aditya7521 avatar Dec 20 '23 12:12 Aditya7521

Any news on it? Facing the same issue

EgorSigolaev avatar Mar 27 '24 15:03 EgorSigolaev

I'm also facing the same issue. The symptoms of the following ticket may be similar.

https://github.com/OneSignal/OneSignal-Android-SDK/issues/1977

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

@Harris-Cww @EgorSigolaev @Aditya7521

In the 5.1.14 release we added a discard boolean to the preventDefault method to address this use-case.

Call event.preventDefault(true) if you want to immediately decide to never display the notification.

  • NOTE: Calls to event.notification.display() will be ignored after this as well.

jkasten2 avatar Jun 24 '24 17:06 jkasten2