Set an Event Delegate
Receive notifications about the in-app message display lifecycle by setting an event delegate. By implementing the event delegate, you can track when an in-app message is shown or closed, control whether an in-app message can be displayed based on your app’s state, and manage the view hierarchy for your app when an in-app message appears.
Make your application a delegate of the SDK’s in-app messaging functionality by using the setEventDelegate method. Set the delegate early in your class’s initialization to make sure that your app can respond to in-app message events.
Use this code to set the event delegate in version 11 of the SDK for iOS.
- Add the
InAppMessageEventDelegateprotocol to your class declaration. - Set your class as the delegate of the SDK for in-app message events early in your class’s initialization.
Use this code to set the event delegate in version 10 of the SDK for iOS.
- Add the
InAppMessageEventDelegateprotocol to your class declaration. - Set your class as the delegate of the SDK for in-app message events early in your class’s initialization.
Use this code to set the event delegate in version 8.1 of the SDK for iOS.
- Add the
InAppMessageEventDelegateprotocol to your class declaration. - Set your class as the delegate of the SDK for in-app message events early in your class’s initialization.
Use this code to set the event delegate in version 8.0 of the SDK for iOS.
- Add the
InAppMessageEventDelegateprotocol to your class declaration. - Set your class as the delegate of the SDK for in-app message events after the SDK is initialized successfully and is operational.
Use this code to set the event delegate in version 7 of the SDK for iOS.
- Add the
MarketingCloudSDKEventDelegateprotocol to your class declaration. - Set your class as the delegate of the SDK for in-app message events early in your class’s initialization.
After you set the event delegate, implement the delegate methods to respond to in-app message events:
- Track Message View States - Respond when messages are shown or closed.
- Prevent or Delay Message Display - Control when messages can be displayed.