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 AppDelegate (or dedicated handler) conform to the ActitoInAppMessagingDelegate protocol. This delegate provides hooks for key points in the in-app messages lifecycle — from presentation to action execution.
class AppDelegate: NSObject, UIApplicationDelegate {
internal func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// more code ...
Actito.shared.inAppMessaging().delegate = self
}
}
extension AppDelegate: ActitoInAppMessagingDelegate {
func actito(_ actito: ActitoInAppMessaging, didPresentMessage message: ActitoInAppMessage) { }
func actito(_ actito: ActitoInAppMessaging, didFinishPresentingMessage message: ActitoInAppMessage) { }
func actito(_ actito: ActitoInAppMessaging, didFailToPresentMessage message: ActitoInAppMessage) { }
func actito(_ actito: ActitoInAppMessaging, didExecuteAction action: ActitoInAppMessage.Action, for message: ActitoInAppMessage) { }
func actito(_ actito: ActitoInAppMessaging, didFailToExecuteAction action: ActitoInAppMessage.Action, for message: ActitoInAppMessage, error: Error?) { }
}
Presentation events
These methods notify you of each stage in an in-app message’s presentation lifecycle:
didPresentMessage: Called right after the in-app message is presented.
func actito(_ actito: ActitoInAppMessaging, didPresentMessage message: ActitoInAppMessage) {
print("About to present in-app message: \(message.id)")
}
didFinishPresentingMessage: Called when the in-app message has been dismissed or closed.
func actito(_ actito: ActitoInAppMessaging, didFinishPresentingMessage message: ActitoInAppMessage) {
print("In-app message finished presenting: \(message.id)")
}
didFailToPresentMessage: Called if an error occurs during presentation.
func actito(_ actito: ActitoInAppMessaging, didFailToPresentMessage message: ActitoInAppMessage) {
print("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.
func actito(_ actito: ActitoInAppMessaging, didExecuteAction action: ActitoInAppMessage.Action, for message: ActitoInAppMessage) {
print("Executed action: \(action.label)")
}
onActionFailedToExecute: Called when the SDK attempted to execute the action but encountered an error.
func actito(_ actito: ActitoInAppMessaging, didFailToExecuteAction action: ActitoInAppMessage.Action, for message: ActitoInAppMessage, error: Error?) {
print("Action failed: \(error?.localizedDescription ?? "Unknown error")")
}