Set up in-app messaging

Incorporate in-app messages to send dynamic, personalized content to people using your app. With in-app messages, you can speak directly to your app’s users when they use your app.

How it works

An in-app message is a message that people see within the app; people won’t see your message until they open your app. To set up in app messaging, install and initialize the CioDataPipelines and CioMessagingInApp packages.

You can also set page rules to display your in-app messages when people visit specific pages in your app. However, to take advantage of page rules, you need to use screen tracking features. Screen tracking tells us the names of your pages and which pages a person is visits, so we can display in-app messages on the correct screens (or “pages”) in your app.

graph LR a[app user triggers
in-app message]-->d{is the app open?} d-->|yes|f[user gets message] d-->|no|e[hold message
until app opens] e-->g{did the message
expire?} g-->|no, wait for user
to open the app|d g-->|yes|h[user doesn't
get the message]

Set up in-app messaging

Use Swift Package Manager to install the CioMessagingInApp package. See Getting Started for installation instructions. Initializing your app with the CioMessagingInApp package sets up your app to receive in-app messages.

import CioDataPipelines
import CioInternalCommon
import CioMessagingInApp
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var storage = DIGraphShared.shared.storage
    var deepLinkHandler = DIGraphShared.shared.deepLinksHandlerUtil

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        var siteId = YOUR_SITE_ID
        
        let config = SDKConfigBuilder(cdpApiKey: YOUR_CDP_API_KEY)
            .autoTrackDeviceAttributes(true)
            .autoTrackUIKitScreenViews()
            .migrationSiteId(siteId)

        CustomerIO.initialize(withConfig: config.build())

        // Initialize messaging features after initializing Customer.io SDK
        MessagingInApp
            .initialize(withConfig: MessagingInAppConfigBuilder(siteId: siteId, region: .US).build())
            .setEventListener(self)

        return true
    }
}   

In-app configuration options

You must pass both of the following configuration options when you initialize the MessagingInApp package.

OptionTypeDefaultDescription
siteIdstringThe Site IDEquivalent to the user name you’ll use to interface with the Journeys Track API; also used with our JavaScript snippets. You can find your Site ID under Settings > Workspace Settings > API Credentials from a set of track API credentials; this determines the workspace that your app listens for in-app messages from.
regionRegion.US or Region.EUThe region your Customer.io account resides in.
Copied to clipboard!
  Contents
Current release
 3.1.3
Is this page helpful?