Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ android.enableJetifier=true
kotlin.code.style=official

# SDK version property
SDK_VERSION_NAME=2.9.0-rc
SDK_VERSION_NAME=2.9.0
8 changes: 5 additions & 3 deletions sdk/src/main/java/cloud/mindbox/mobile_sdk/Mindbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ object Mindbox : MindboxLog {

private val mutex = Mutex()

private val inAppMutex = Mutex()

private var firstInitCall: Boolean = true

/**
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ internal class PushPermissionInAppAction(

override fun execute(mindboxView: MindboxView?): InAppActionResult {
mindboxLogI("In-app for push activation was clicked")
mindboxView?.requestPermission()
return InAppActionResult(
redirectUrl = "",
payload = payload,
shouldDismiss = shouldDismiss()
shouldDismiss = shouldDismiss(),
onCompleted = { mindboxView?.requestPermission() }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package cloud.mindbox.mobile_sdk.inapp.presentation.actions
internal data class InAppActionResult(
val redirectUrl: String,
val payload: String,
val shouldDismiss: Boolean
val shouldDismiss: Boolean,
val onCompleted: (() -> Unit)? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal abstract class AbstractInAppViewHolder<T : InAppType> :
var redirectUrl: String
var payload: String
var shouldDismiss: Boolean

currentDialog.setSingleClickListener {

val inAppData = inAppActionHandler.handle(
Expand All @@ -85,11 +86,15 @@ internal abstract class AbstractInAppViewHolder<T : InAppType> :
redirectUrl,
payload
)

if (shouldDismiss) {
inAppCallback.onInAppDismissed(wrapper.inAppType.inAppId)
mindboxLogI("In-app dismissed by click")
hide()
}

inAppData.onCompleted?.invoke()

InAppMessageViewDisplayerImpl.isActionExecuted = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cloud.mindbox.mobile_sdk.inapp.presentation
import cloud.mindbox.mobile_sdk.inapp.presentation.actions.PushPermissionInAppAction
import cloud.mindbox.mobile_sdk.inapp.presentation.actions.RedirectUrlInAppAction
import io.mockk.mockk
import io.mockk.verify
import org.junit.Assert
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -51,7 +50,6 @@ class InAppActionsTest {

val data = action.execute(mindboxView)

verify { mindboxView.requestPermission() }
Assert.assertEquals("", data.redirectUrl)
Assert.assertEquals(payload, data.payload)
Assert.assertEquals(true, data.shouldDismiss)
Expand Down