Skip to content

Commit 817a9cf

Browse files
committed
fix: call updateNotificationAsOpened in a destinate coroutine scope
1 parent 54c0fd1 commit 817a9cf

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/lifecycle/impl/NotificationLifecycleService.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.onesignal.common.JSONUtils
77
import com.onesignal.common.events.CallbackProducer
88
import com.onesignal.common.events.EventProducer
99
import com.onesignal.common.exceptions.BackendException
10+
import com.onesignal.common.threading.OSPrimaryCoroutineScope
1011
import com.onesignal.core.internal.application.AppEntryAction
1112
import com.onesignal.core.internal.application.IApplicationService
1213
import com.onesignal.core.internal.config.ConfigModelStore
@@ -138,15 +139,17 @@ internal class NotificationLifecycleService(
138139

139140
postedOpenedNotifIds.add(notificationId)
140141

141-
try {
142-
_backend.updateNotificationAsOpened(
143-
appId,
144-
notificationId,
145-
subscriptionId,
146-
deviceType,
147-
)
148-
} catch (ex: BackendException) {
149-
Logging.error("Notification opened confirmation failed with statusCode: ${ex.statusCode} response: ${ex.response}")
142+
OSPrimaryCoroutineScope.execute {
143+
try {
144+
_backend.updateNotificationAsOpened(
145+
appId,
146+
notificationId,
147+
subscriptionId,
148+
deviceType,
149+
)
150+
} catch (ex: BackendException) {
151+
Logging.error("Notification opened confirmation failed with statusCode: ${ex.statusCode} response: ${ex.response}")
152+
}
150153
}
151154
}
152155

0 commit comments

Comments
 (0)