Configure Marketing Cloud Engagement
Runtime Toggles
Set the Event Delegate
Track View States
Prevent or Delay Display
Customize Fonts
Configure Push Permission Authorization
Event Tracking
Handle URLs
Data Protection and Privacy
Changelog
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.
InAppMessageEventDelegate protocol to your class declaration.1// Add the InAppMessageEventDelegate protocol to your class declaration
2class MyViewController: UIViewController, InAppMessageEventDelegate {
3
4 override func viewDidLoad() {
5 super.viewDidLoad()
6
7 // Set your class as the delegate of the SDK for in-app message events
8 InAppMessagingFeature.requestSdk { iam in
9 iam?.setEventDelegate(self)
10 }
11 }
12}Use this code to set the event delegate in version 10 of the SDK for iOS.
InAppMessageEventDelegate protocol to your class declaration.1// Add the InAppMessageEventDelegate protocol to your class declaration
2class MyViewController: UIViewController, InAppMessageEventDelegate {
3
4 override func viewDidLoad() {
5 super.viewDidLoad()
6
7 // Set your class as the delegate of the SDK for in-app message events
8 MarketingCloudSdk.requestSdk { mc in
9 mc?.setEventDelegate(self)
10 }
11 }
12}Use this code to set the event delegate in version 8.1 of the SDK for iOS.
InAppMessageEventDelegate protocol to your class declaration.1// Add the InAppMessageEventDelegate protocol to your class declaration
2class MyViewController: UIViewController, InAppMessageEventDelegate {
3
4 override func viewDidLoad() {
5 super.viewDidLoad()
6
7 // Set your class as the delegate of the SDK for in-app message events
8 SFMCSdk.requestPushSdk { mp in
9 mp.setEventDelegate(self)
10 }
11 }
12}Use this code to set the event delegate in version 8.0 of the SDK for iOS.
InAppMessageEventDelegate protocol to your class declaration.1// Add the InAppMessageEventDelegate protocol to your class declaration
2class MyViewController: UIViewController, InAppMessageEventDelegate {
3
4 override func viewDidLoad() {
5 super.viewDidLoad()
6
7 // Set your class as the delegate of the SDK for in-app message events
8 // Make sure that the SDK is operational
9 SFMCSdk.mp.setEventDelegate(self)
10 }
11}Use this code to set the event delegate in version 7 of the SDK for iOS.
MarketingCloudSDKEventDelegate protocol to your class declaration.1// Add the MarketingCloudSDKEventDelegate protocol to your class declaration
2class MyViewController: UIViewController, MarketingCloudSDKEventDelegate {
3
4 override func viewDidLoad() {
5 super.viewDidLoad()
6
7 // Set your class as the delegate of the SDK for in-app message events
8 MarketingCloudSDK.sharedInstance().sfmc_setEventDelegate(self)
9 }
10}After you set the event delegate, implement the delegate methods to respond to in-app message events: