# Set up in-app messaging

 There's a new version available!

These pages cover version 3 of our SDK, but a newer version is available. In general, we suggest that you update to the latest version to take advantage of new features and fixes.

*   Are you new to our SDKs? [Check out the latest docs.](/integrations/sdk/ios/getting-started)
*   Otherwise, [learn about updating to the latest version](/integrations/sdk/ios/whats-new/)

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[](#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](/integrations/sdk/ios/tracking/track-events/#auto-screenview) 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.

## Set up in-app messaging[](#set-up-in-app-messaging)

Use Swift Package Manager to install the `CioMessagingInApp` package. See [Getting Started](/integrations/sdk/ios/quick-start-guide) for installation instructions. Initializing your app with the `CioMessagingInApp` package sets up your app to receive in-app messages.

```swift
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[](#anonymous-messages)

As of version 3.14, you can send [anonymous in-app messages](/journeys/anonymous-in-app/). 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](/journeys/messages-and-webhooks/in-app/lead-form/) for more information.

## In-app configuration options[](#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 *Workspace Settings* > *API Credentials*](https://fly.customer.io/env/last/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.