Skip to main content

Example App — Android SDK

In-app messaging demo with all four render types. UI is built programmatically — copy MainActivity.kt into a host app (no bundled layout XML).

Prerequisites​

  • Android Studio
  • Your CDP API key

Step 1 — Open the project​

git clone https://github.com/opencdp/opencdp-android-sdk.git
cd opencdp-android-sdk/example

Copy the Kotlin sources into your app module and wire ExampleApp + MainActivity in AndroidManifest.xml (see example README).

Step 2 — Configure credentials​

In ExampleApp.kt, set:

ValuePlaceholder
CDP API keyYOUR_CDP_API_KEY
enableInAppMessagestrue

Step 3 — Run on device or emulator​

Build and run. The demo uses person ID user_123.

Step 4 — Use the demo​

ControlPurpose
Screen chips (home, cart, profile, inbox)Set logical screen for page rules
Identify userOpenCDP.identify(...)
Sync in-appOpenCDP.syncInAppMessages(...)
Reset local in-app UIClears inline/banner + inApp.resetSession()
Clear identityOpenCDP.clearIdentity()

Render types​

render_typeExample UI
modalAlertDialog
bannerDark card at top of screen
inlineGray card in inline list
inbox_cardSame inline list (use inbox screen)

Step 5 — Push setup (optional)​

See ExampleFirebaseService.kt and Push notifications.

Verify it worked​

  • Log panel shows modal, banner, or inline / inbox_card after sync
  • With debug = true, Logcat shows GET /v1/in-app/messages/sync