In-App Messaging in iOS Apps that use SDK Version 10
The processes for implementing and customizing in-app messaging have been updated in version 10 of the SDK. To upgrade your app to version 10 of the SDK, first update the initialization code. Then, use these code examples to update the in-app messaging code in your app.
Optional Methods
To make your application a delegate of the SDK’s in-app messaging functionality, use setEventDelegate. This code example shows how to set the event delegate using version 10 of the SDK.
1// adhere to the InAppMessageEventDelegate protocol in your class declaration2class MyViewController: UIViewController, InAppMessageEventDelegate3...4// somewhere in your implementation, set your class as the delegate of the SDK for In-App Message events5// this should be done early in your class’s initialization, if possible6MarketingCloudSdk.requestSdk { mc in7 mc?.setEventDelegate(self)8}
Delay Message Display
Use this code example to prevent or delay the display of an in-app message.
1// If you previously captured the messageId, you can show the In-App Message2// later (for example, if you returned false from sfmc_shouldShowInAppMessage()3// because your UI or app logic couldn’t be interrupted).4if(self.showMessageId != nil){5 MarketingCloudSdk.requestSdk{ mc in6 mc?.showInAppMessage(messageId: self.showMessageId)7}8}
Customize Display
Use this code example to customize the font used in an in-app message.
1MarketingCloudSdk.requestSdk{ mc in2 mc?.setInAppMessage(fontName: "Zapfino")3}