iterable-android-sdk icon indicating copy to clipboard operation
iterable-android-sdk copied to clipboard

In-App Messages Flickering and Anchored Incorrectly (Top Instead of Bottom)

Open thushenIpnos opened this issue 1 year ago • 1 comments
trafficstars

We are experiencing an issue with Iterable's Android SDK where in-app messages, which should be anchored at the bottom of the screen, sometimes appear at the top. The messages flicker between the top and bottom sporadically and can be anchored at the top when they should be at the bottom. This behavior seems tied to whether the home screen is fully loaded.

We previously used a 1-second delay with iterableManager.setAutoDisplayPaused(false) in a custom class called IterableMainActivityObserver to fix the issue, and it worked for a couple of years. However, the issue has returned, and now we have to increase the delay to approximately 20 seconds to stop the flickering and incorrect placement. By increasing the delay to 20 seconds (to account for slower phones), we can assume the home screen will be fully loaded with all its content, which prevents the message from flickering or being misplaced.

Using the Layout Inspector, we observed that the Iterable layout is correctly layered on top of our home screen view. Therefore, we are not sure why Iterable only works without bugging out when the home screen has fully loaded the content on the screen.

Here is the IterableMainActivityObserver class:

class IterableMainActivityObserver : DefaultLifecycleObserver {

    private var job: Job? = null

    private val iterableManager: IterableManager by KoinJavaComponent.inject(IterableManager::class.java)

    override fun onResume(owner: LifecycleOwner) {
        job = owner.lifecycleScope.launch {
            delay(1000L) // Previously worked with 1-second delay, now needs 20 seconds (20000L).
            iterableManager.setAutoDisplayPaused(false)
        }
    }

    override fun onPause(owner: LifecycleOwner) {
        job?.cancel()
        iterableManager.setAutoDisplayPaused(true)
    }
}

Do you have any suggestions on how we can resolve this issue more effectively?

thushenIpnos avatar Oct 16 '24 14:10 thushenIpnos