Implement In-App Messaging on iOS

To use certain in-app messaging features, such as button actions, some SDK configurations are needed. The following sections describe these configurations.

The SDK handles actions for Notification Settings and Location Settings, while actions for Web URL and App URL require that you implement URL handling.

To control aspects of message display and to get information about the in-app message display lifecycle, use the SDK’s optional delegate functionality.

To make your application a delegate of the SDK’s in-app messaging functionality, use sfmc_setEventDelegate as shown in the following examples.

The sfmc_didShowInAppMessage and sfmc_didCloseInAppMessage delegate methods help ensure that you can appropriately manage your app’s view state. In-app messages are shown as the top view controller in your app’s hierarchy. Your application must be able to respond to a view appearing or disappearing.

You can delay or prevent an in-app message’s display using the sfmc_shouldShowInAppMessage method. For example, you can choose to prevent an in-app message from displaying during the loading process, sign-in flow, and other situations. To prevent or delay message display, set the shouldShowInAppMessage method to return false.

Furthermore, you can capture in-app message data and use it for displaying the specific message at a later time. For example, you can present the message after an end user has successfully signed in. To present the message later, use the following methods.

  • sfmc_messageIdForMessage
  • sfmc_showInAppMessage

By default, in-app messages use your device’s system font. However, you can override the default font face to customize the appearance of an in-app message's title, body, and button labels.

You can’t alter the font size since the message’s design defines it.

To set the display font, use the sfmc_setInAppMessageFontName method to pass the SDK a valid font name for the device’s installed fonts, or your app’s custom fonts.

If the font is invalid, the SDK returns false and reverts to using the system font.