This error occurs because of a timing issue. The mobile SDK attempts to display an in-app message just as the target screen is destroyed. On Android, this is an Activity, and on iOS, it is a UIViewController.
This usually happens during rapid screen transitions, such as when:
- The splash screen closes.
- The app moves to the background.
- The app switches quickly between screens.
In this situation, the SDK is ready to show the message, but the screen it needs is no longer available. As a result, the SDK logs an error and doesn't display the in-app message.
How does this happen on a splash screen?
This issue often appears when an in-app message is triggered during app launch.
A typical sequence looks like this:
- The app starts and shows a splash screen.
- The mobile SDK initializes early in the launch flow.
- An event, such as
session_startor an earlyidentify_customercall, triggers an in-app message campaign. - The SDK fetches and prepares the message.
- At the same time, the app finishes loading and moves from the splash screen to the main screen.
- If the SDK tries to show the message while the splash screen is being destroyed, the display fails because the target screen is no longer valid.
Recommended solution
Adding a 1–2 second display delay is a practical solution.
This gives the app enough time to move past temporary screens and settle on a stable UI before the SDK tries to display the in-app message.
Other approaches to consider
For a more reliable fix, consider these options:
- Delay SDK initialization
Initialize the mobile SDK later in the startup flow, rather than during the earliest splash-screen phase. This delays in-app message fetching until a stable screen is active. - Change message placement
Avoid showing in-app messages on temporary screens such as splash screens. Trigger them on more stable screens, such as the main screen, instead.
Mobile SDK behavior
The SDK ties in-app message display to the lifecycle of the screen it originally targets.
If that screen is destroyed before the message appears, the display attempt ends, and the SDK logs an error. The mobile SDK doesn't retry the same message automatically on the next screen.