OneSignal-Android-SDK
OneSignal-Android-SDK copied to clipboard
[Bug]: preventDefault not working as expected if app relaunch within 30s
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 thanks for reaching out! We're working on reproducing this and will get back to you as soon as possible.
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
@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.
Any news on it? Facing the same issue
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
Hello @jennantilla Could you please provide any updates on the status of this issue?
@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.