Skip to content

Commit 3582e9f

Browse files
nan-lijinliu9508
authored andcommitted
fix: send receive receipt even when preventDefault is called (#2512)
1 parent 97e439b commit 3582e9f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/generation/impl/NotificationGenerationProcessor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ internal class NotificationGenerationProcessor(
232232
// Notification channel disable or not displayed
233233
// save notification as dismissed to avoid user re-enabling channel and notification being displayed due to restore
234234
markNotificationAsDismissed(notificationJob)
235-
return
236235
}
237236

237+
// Always call notificationReceived, regardless of wasDisplayed
238238
_lifecycleService.notificationReceived(notificationJob)
239239
}
240240

OneSignalSDK/onesignal/notifications/src/test/java/com/onesignal/notifications/internal/generation/NotificationGenerationProcessorTests.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class NotificationGenerationProcessorTests : FunSpec({
168168
mocks.notificationGenerationProcessor.processNotificationData(context, 1, mocks.notificationPayload, false, 1111)
169169

170170
// Then
171+
// notificationReceived should be called
172+
coVerify(exactly = 1) {
173+
mocks.notificationLifecycleService.notificationReceived(any())
174+
}
171175
}
172176

173177
test("processNotificationData should display notification when external callback takes longer than 30 seconds") {
@@ -211,6 +215,10 @@ class NotificationGenerationProcessorTests : FunSpec({
211215
mocks.notificationGenerationProcessor.processNotificationData(context, 1, mocks.notificationPayload, false, 1111)
212216

213217
// Then
218+
// notificationReceived should be called
219+
coVerify(exactly = 1) {
220+
mocks.notificationLifecycleService.notificationReceived(any())
221+
}
214222
}
215223

216224
test("processNotificationData should display notification when foreground callback takes longer than 30 seconds") {

0 commit comments

Comments
 (0)