Set up in-app messaging
UpdatedIncorporate 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.
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 AppDelegateWithCioIntegration: CioAppDelegateWrapper<AppDelegate> {}
class AppDelegate: UIResponder, UIApplicationDelegate {
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
}
}
Anonymous messages
As of version 3.14, you can send anonymous in-app messages. These are messages that are sent only to people you haven’t identified yet.
You can use lead forms in anonymous messages to capture leads and potentially identify people when they submit your form. For example, you could use a lead form and offer a coupon or newsletter to people who provide their email addresses. See Lead forms for more information.
In-app configuration options
You must pass both of the following configuration options when you initialize the MessagingInApp
package.
Option | Type | Default | Description |
---|---|---|---|
siteId | string | The 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. | |
region | Region.US or Region.EU | The region your Customer.io account resides in. |