Packages and configuration options
The SDK consists of a few packages. You'll get the most value out of Customer.io when you use all our packages together, but this lets you omit packages for features you don't intend to use.
SDK packages
To minimize our SDK’s impact on your app’s size, we’ve split the SDK into packages. You can limit your install to the packages that you need for your project.
You install the SDK with Swift Package Manager. When you add https://github.com/customerio/customerio-ios.git in Xcode, you choose products from the list below. Most product names don’t have the Cio prefix, but you import each one with the prefix, like import CioDataPipelines for the DataPipelines product.
You must install the DataPipelines product. It lets you identify people, which you must do before you can send them messages, track their events, etc.
| Product | Import | Required? | Description |
|---|---|---|---|
DataPipelines | CioDataPipelines | Yes | identify people and track events |
MessagingPushAPN | CioMessagingPushAPN | No | Receive push notifications over Apple’s Push Notification Service (APNs) |
MessagingPushFCM | CioMessagingPushFCM | No | Receive push notifications over Firebase Cloud Messaging (FCM). Add CioFirebaseWrapper too. |
CioFirebaseWrapper | CioFirebaseWrapper | With FCM | Connects the SDK to the Firebase Messaging in your app. It doesn’t include Firebase, so add Firebase Messaging to your app yourself. |
MessagingPush | CioMessagingPush | No | The core push module, for apps that don’t use MessagingPushAPN or MessagingPushFCM. Those products already include it. Available in version 5.4.0 and later. |
MessagingInApp | CioMessagingInApp | No | Receive in-app messages |
MessagingInbox | CioMessagingInbox | No | Show the visual inbox in your app |
Location | CioLocation | No | Enrich people’s profiles with accurate device location |
LocationGeofence | CioLocationGeofence | No | Monitor geofences and send location-based events. Requires Location. |
LiveActivities | CioLiveActivities | No | Start and track Live Activities from your app target |
LiveActivities_Attributes | CioLiveActivities_Attributes | No | The Live Activity types your widget extension shares with your app. Add it to both targets. |
LiveActivities_Templates | CioLiveActivities_Templates | No | Customer.io’s built-in Live Activity templates for your widget extension |
Version 5.3.2 is the last version of the SDK on CocoaPods. If your app gets the SDK from CocoaPods, see Move from CocoaPods to Swift Package Manager.
Configuration options
You’ll call configuration options before you initialize the SDK with SDKConfigBuilder. When you initialize the SDK, you can pass configuration options. In most cases, you’ll want to stick with the defaults, but you might do things like change the logLevel when testing updates to your app.
import CioDataPipelines
let config = SDKConfigBuilder(cdpApiKey: "YOUR_CDP_API_KEY") // Mandatory for all customers
.migrationSiteId("YOUR_SITE_ID") // Mandatory only for migrating customers
.autoTrackDeviceAttributes(true)
.region(.EU)
CustomerIO.initialize(withConfig: config.build()) | Option | Type | Default | Description |
|---|---|---|---|
cdpApiKey | string | Required: the key you’ll use to initialize the SDK and send data to Customer.io | |
region | . or . | . | Required if your account is in the EU region. This sets your account region in the format Region.. |
apiHost | string | The domain you’ll proxy requests through. You’ll only need to set this (and cdnHost) if you’re proxying requests. | |
autoTrackDeviceAttributes | boolean | true | Automatically gathers information about devices, like operating system, device locale, model, app version, etc |
autoTrackUIKitScreenViews | boolean | false | For UIKit-based apps: if true, the SDK automatically sends screen events for every screen your audience visits. |
cdnHost | string | The domain you’ll fetch configuration settings from. You’ll only need to set this (and apiHost) if you’re proxying requests. | |
logLevel | string | error | Sets the level of logs you can view from the SDK. Set to debug or info to see more logging output. |
migrationSiteId | string | Required if you’re updating from 2.x: the credential for previous versions of the SDK. This key is used to send remaining tasks to Customer.io when your audience updates your app. | |
screenViewUse | . or . | all | screenView: . (Default): Screen events are sent to Customer.io. You can use these events to build segments, trigger automations, and target in-app messages.screenView: inApp: Screen view events not sent to Customer.io. You’ll only use them to target in-app messages based on page rules. |
trackApplicationLifecycleEvents | boolean | true | Set to false if you don’t want the app to send lifecycle events |
Proxying requests
By default, requests go through our domain at cdp.customer.io. You can proxy requests through your own domain to provide a better privacy and security story, especially when submitting your app to app stores.
To proxy requests, you’ll need to set the apiHost and cdnHost properties in your SDKConfigBuilder. While these are separate settings, you should set them to the same URL.
While you need to initialize the SDK with a cdpApiKey, you can set this to any value you want. You only need to pass your actual key when you send requests from your server backend to Customer.io. If you want to secure requests to your proxy server, you can set the cdpApiKey to a value representing basic authentication credentials that you handle on your own. See proxying requests for more information.
let config = SDKConfigBuilder(cdpApiKey: "YOUR_CDP_API_KEY")
.apiHost("YOUR_PROXY_HOST")
.cdnHost("YOUR_CDN_HOST")
CustomerIO.initialize(withConfig: config.build())visionOS Support
The iOS SDK supports VisionOS. We have a handy sample app that demonstrates how to use the SDK with Vision Pro devices, along with a handy readme, in the Apps/VisionOS directory.
We’ve tested the iOS SDK with visionOS using Swift Package Manager.
Also, for now, we only support Apple’s Push Notification Service (APNS) for visionOS. You won’t be able to send push notifications to Vision Pro devices using Firebase Cloud Messaging (FCM).