Skip to main content
SDK Version

Advanced

The following guides cover advanced features and customization options available in the Actito SDK.

These topics are optional and can be adopted selectively based on your application’s requirements. You can safely skip any sections that are not relevant to your use case or implementation strategy.

Lifecycle

When using the In-app Messages module to present in-app messages, you can listen to a series of lifecycle events emitted during the presentation process. In more advanced implementations, these events can be leveraged to execute additional logic — such as tracking analytics, updating application state, or triggering custom navigation behaviors.

To do this, make your Activity (or a dedicated handler) implement the ActitoInAppMessaging.MessageLifecycleListener. This listener provides hooks for key points in the in-app message lifecycle — from presentation to action execution.

class MainActivity : AppCompatActivity(), ActitoInAppMessaging.MessageLifecycleListener {
override fun onCreate(savedInstanceState: Bundle?) {
// more code ...

Actito.inAppMessaging().addLifecycleListener(this)
}

override fun onDestroy() {
// more code ...

Actito.inAppMessaging().removeLifecycleListener(this)
}

override fun onMessagePresented(message: ActitoInAppMessage) { }

override fun onMessageFinishedPresenting(message: ActitoInAppMessage) { }

override fun onMessageFailedToPresent(message: ActitoInAppMessage) { }

override fun onActionExecuted(message: ActitoInAppMessage, action: ActitoInAppMessage.Action) { }

override fun onActionFailedToExecute(message: ActitoInAppMessage, action: ActitoInAppMessage.Action, error: Exception?) { }
}

Presentation events

These methods notify you of each stage in an in-app message’s presentation lifecycle:

  • onMessagePresented: Called right after the in-app message is presented.
override fun onMessagePresented(message: ActitoInAppMessage) {
Log.i(TAG, "Presented in-app message: ${message.id}")
}
  • onMessageFinishedPresenting: Called when the in-app message has been dismissed or closed.
override fun onMessageFinishedPresenting(message: ActitoInAppMessage) {
Log.i(TAG, "In-app message finished presenting:: ${message.id}")
}
  • onMessageFailedToPresent: Called if an error occurs during presentation.
override fun onMessageFailedToPresent(message: ActitoInAppMessage) {
Log.i(TAG, "Failed to present in-app message: ${message.id}")
}

Action events

These methods notify you of each stage in an action’s execution lifecycle:

  • onActionExecuted: Called when the action has been successfully performed.
override fun onActionExecuted(message: ActitoInAppMessage, action: ActitoInAppMessage.Action) {
Log.i(TAG, "Executed action: ${action.label}")
}
  • onActionFailedToExecute: Called when the SDK attempted to execute the action but encountered an error.
override fun onActionFailedToExecute(message: ActitoInAppMessage, action: ActitoInAppMessage.Action, error: Exception?) {
Log.i(TAG, "Action failed: $error")
}