Example App — iOS SDK
SwiftUI in-app messaging demo covering all four render types via InAppDemoView.
Prerequisites
- Xcode 14+
- Your CDP API key
Step 1 — Open the project
git clone https://github.com/opencdp/opencdp-ios-sdk.git
cd opencdp-ios-sdk/Example
open OpenCDPExample.xcodeproj
Step 2 — Configure credentials
In OpenCDPExampleApp.swift, set your CDP API key and confirm in-app is enabled:
OpenCDPConfig(
cdpApiKey: "YOUR_CDP_API_KEY",
debug: true,
enableInAppMessages: true,
enableInAppRealtime: true,
inAppSyncLimit: 10
)
Step 3 — Run on simulator or device
Select a target and run. Default test person ID is user_123.
Step 4 — Use the demo
| Control | Purpose |
|---|---|
| Screen buttons | inApp.setCurrentScreen(...) + page rules |
| Identify user | OpenCDP.shared.identify(...) |
| Sync in-app | syncInAppMessages(screen:limit:) |
| Reset local in-app UI | Clears SwiftUI state + inApp.resetSession() |
| Clear identity | OpenCDP.shared.clearIdentity() |
Render types
render_type | Example UI |
|---|---|
modal | SwiftUI sheet (InAppModalView) |
banner | Top overlay (InAppBannerView) |
inline | Card in scroll list (InAppInlineCardView) |
inbox_card | Same inline card (switch to inbox screen) |
Step 5 — Real push (optional)
Forward the APNs device token in AppDelegate and add a Notification Service Extension for rich images. See Push notifications.
Verify it worked
- Log panel shows render type +
delivery_idafter sync - With
debug: true, Xcode console shows sync and interaction POSTs