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:
| Value | Placeholder |
|---|---|
| CDP API key | YOUR_CDP_API_KEY |
enableInAppMessages | true |
Step 3 — Run on device or emulator
Build and run. The demo uses person ID user_123.
Step 4 — Use the demo
| Control | Purpose |
|---|---|
Screen chips (home, cart, profile, inbox) | Set logical screen for page rules |
| Identify user | OpenCDP.identify(...) |
| Sync in-app | OpenCDP.syncInAppMessages(...) |
| Reset local in-app UI | Clears inline/banner + inApp.resetSession() |
| Clear identity | OpenCDP.clearIdentity() |
Render types
render_type | Example UI |
|---|---|
modal | AlertDialog |
banner | Dark card at top of screen |
inline | Gray card in inline list |
inbox_card | Same inline list (use inbox screen) |
Step 5 — Push setup (optional)
See ExampleFirebaseService.kt and Push notifications.
Verify it worked
- Log panel shows
modal,banner, orinline/inbox_cardafter sync - With
debug = true, Logcat showsGET /v1/in-app/messages/sync