diff --git a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt index 5bcfe6e52..004759c0a 100644 --- a/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt +++ b/sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt @@ -95,6 +95,8 @@ object Mindbox : MindboxLog { private val mutex = Mutex() + private val inAppMutex = Mutex() + private var firstInitCall: Boolean = true /** @@ -522,7 +524,7 @@ object Mindbox : MindboxLog { if (activity != null && lifecycleManager.isCurrentActivityResumed) { inAppMessageManager.registerCurrentActivity(activity) mindboxScope.launch { - mutex.withLock { + inAppMutex.withLock { firstInitCall = false inAppMessageManager.listenEventAndInApp() inAppMessageManager.initLogs() @@ -576,8 +578,8 @@ object Mindbox : MindboxLog { ) if (firstInitCall) { mindboxScope.launch { - mutex.withLock { - InitializeLock.await(InitializeLock.State.SAVE_MINDBOX_CONFIG) + InitializeLock.await(InitializeLock.State.SAVE_MINDBOX_CONFIG) + inAppMutex.withLock { if (!firstInitCall) return@launch firstInitCall = false inAppMessageManager.listenEventAndInApp()