Authentication

To use the SDK, you’ll need to get two kinds of keys: A Write Key to send data to Customer.io and a Site ID, telling the SDK which workspace your messages come from.

To get your SDK keys and send data to the right places, you’ll need to set up your app as a data sourceA source is a website or server that you want to capture data from—it’s a source of data! in Customer.io, and route it to your workspace. The SDK lets you route data to any number of destinations, but you must connect it to your workspace destination to send data, like the people you identify, the events you track, and so on, to Customer.io.

If you haven’t already set up your app as a data source in Customer.io, do that first.

API Keys you’ll need

  1. Write Key: This key lets you send data to Customer.io. You’ll need it to initialize the SDK. You’ll get this key when you set up your mobile app as a data sourceA source is a website or server that you want to capture data from—it’s a source of data! in Customer.io.
  2. Site ID: This key tells the SDK which workspace your messages come from. You’ll use it to initialize the CioMessagingInApp package and send in-app messages from your workspace. If you’re upgrading from a previous version of the Customer.io SDK, it also serves as the migrationSiteId.

Get your write key

You’ll use your write key to initialize the SDK and send data to Customer.io; you’ll get this key from your mobile app’s data sourceA source is a website or server that you want to capture data from—it’s a source of data! in Customer.io. If you don’t already have a mobile data source, you’ll need to set one up.

  1. Go to the Data Pipelines tab.
  2. On the Connections page under Sources, select your Mobile: iOS source. If there is no iOS source, see Set up a new source below.
    the connections page, showing an ios source connected to a journeys destination
    the connections page, showing an ios source connected to a journeys destination
  3. Go to Settings and find your Write Key. Copy this key into your initialization call. If you’re upgrading from a previous version of the SDK, you should keep the siteId that you used in previous versions as the migrationSiteId in your config.
    get your CDP API Key from your source's settings page
    get your CDP API Key from your source's settings page
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
         ...
    
         let config = SDKConfigBuilder(cdpApiKey: "YOUR_CDP_API_KEY")
             .migrationSiteId(YOUR_SITE_ID)
             .autoTrackDeviceAttributes(true)
    
         CustomerIO.initialize(withConfig: config.build())
     }

 You’re not done yet

You still need your 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 to initialize the CioMessagingInApp package and to support people updating your app from a previous version of Customer.io SDK. See Get your Site ID below.

Set up a new source

If you don’t already have a write key, you’ll need to set up a new data sourceA source is a website or server that you want to capture data from—it’s a source of data!. The source represents your app and the stream of data that you’ll send to Customer.io. You’ll also tell Customer.io where to send your data—your workspace in Customer.io and other destinations where you can use mobile data, like Mixpanel, your data warehouse, and so on.

  1. Go to the Data Pipelines tab. On the Connections page under Sources, click Add New.
  2. Select the Mobile: iOS source and then click Add Source.
    set up your iOS source
    set up your iOS source
  3. Enter a Name for the source, like “My iOS App”.
  4. We’ll present you with a CDP API Key that you’ll use to initialize the SDK. Copy this key and keep it handy.
  5. Click Complete Setup to finish setting up your source. But you’re not done yet!
    Set your name, get your CDP API Key, and click Complete Setup
    Set your name, get your CDP API Key, and click Complete Setup
  6. Select your Journeys workspace on the right-side of the Connections page.
    select the Journeys destination you want to connect your iOS source to
    select the Journeys destination you want to connect your iOS source to
  7. Click Add a destination.
  8. Select the iOS source you set up in previous steps. This tells Customer.io to send data from your app to your Customer.io workspace.
    connect your iOS source to your journeys workspace
    connect your iOS source to your journeys workspace

Now your connections page wil show that your iOS source is connected to your Journeys workspace. Hover over a source or destination to see its active connections.

the connections page, showing an ios source connected to a journeys destination
the connections page, showing an ios source connected to a journeys destination

Get your Site ID

You’ll use your Site ID to initialize the CioMessagingInApp package and send in-app messages from your workspace.

If you’re upgrading from a previous version, my can also set your Site ID as your migrationSiteId. This key is used to send remaining tasks to Customer.io when your audience updates your app.

  1. Go to and select Workspace Settings in the upper-right corner of the Customer.io app and go to API and Webhook Credentials.

  2. Copy the Site ID for the set of credentials that you want to send your in-app messages from. If you don’t have a set of credentials, click Create Tracking API Key.

    find your site ID
    find your site ID
  3. You’ll use this key to initialize the CioMessagingInApp package.

     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
         ...
    
         let siteId = "YOUR_SITE_ID"
    
         let config = SDKConfigBuilder(cdpApiKey: "YOUR_CDP_API_KEY")
             .migrationSiteId(siteId)
             .autoTrackDeviceAttributes(true)
    
         CustomerIO.initialize(withConfig: config.build())
    
         MessagingInApp
             .initialize(withConfig: MessagingInAppConfigBuilder(siteId: siteId, region: .US).build())
             .setEventListener(self)
     }
Copied to clipboard!
  Contents
Current release
 3.1.3
Is this page helpful?