Skip to main content

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​

ControlPurpose
Screen buttonsinApp.setCurrentScreen(...) + page rules
Identify userOpenCDP.shared.identify(...)
Sync in-appsyncInAppMessages(screen:limit:)
Reset local in-app UIClears SwiftUI state + inApp.resetSession()
Clear identityOpenCDP.shared.clearIdentity()

Render types​

render_typeExample UI
modalSwiftUI sheet (InAppModalView)
bannerTop overlay (InAppBannerView)
inlineCard in scroll list (InAppInlineCardView)
inbox_cardSame 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_id after sync
  • With debug: true, Xcode console shows sync and interaction POSTs