Skip to content

The Android SDK

The Android SDK (com.crm.sdk) puts PurrCRM inside your Kotlin app. It talks to PurrCRM and keeps the state. Your app either draws every screen itself, with its own views or Compose, or adds the built-in screens, which draw the messenger and your in-app messages over your app for you.

You add the library, make one Crm in your Application, hand it your signed-in user’s token, and it does the rest:

  • In-app messages: banners, posts, carousels and surveys your team writes. The SDK checks in for them, decides which one is due, and hands it to you to draw. What people do with each goes back to PurrCRM.
  • The messenger: conversations with your team, replies arriving live, typing and Seen, pictures and files, ratings, a help bot, the user’s tickets and new tickets from your team’s forms, and chats with people who haven’t signed in.
  • The help center: your articles, searched and read in the app.
  • Product events: the app opening and closing, screens, permission changes, taps on pushes and links, sent in batches by itself, plus events of your own.
  • Pushes: it recognises PurrCRM‘s pushes, keeps the unread counts right, and opens the page a tapped push names.
  • Links: links that open a place in your app on a phone that has it, through an install too.
  • Preferences: which topics people hear about, and how.

Each part gives you state to observe (a StateFlow) and calls to make. The screens are yours:

The SDK gives youYou draw
crm.messenger.stateThe messenger’s home: open conversations, tickets, articles, the help bot’s opening
crm.conversation(id).stateA conversation: its parts, the composer, messages sending or failed, the reply line, the rating, the help bot’s buttons
crm.uploadPicture(...), addPicture, addFileThe picture and file pickers, thumbnails and progress
crm.ticketsThe list of tickets, a ticket, and a new ticket’s form
crm.helpThe help center: collections, search, an article, “Was this helpful?”
crm.inApp.banner, crm.inApp.nextBanners floating over your app; posts, carousels and surveys
crm.noticesThe inbox of notices, and your bell
crm.preferences(), crm.offersByPush()A screen of topics, and the offers-by-push switch
crm.unreadBadges
crm.publicAppYour brand’s colour and logo, and which parts are switched on

In Compose, a screen collects the state and calls the SDK back:

MessengerButton.kt
@Composable
fun MessengerButton(crm: Crm, open: () -> Unit) {
val unread by crm.unread.collectAsState()
BadgedBox(badge = { if (unread > 0) Badge { Text("$unread") } }) {
IconButton(onClick = open) {
Icon(Icons.Outlined.ChatBubbleOutline, contentDescription = "Messages")
}
}
}

Each page in this section starts with what you draw for its part.

  • Android 5.0 (API 21) or later. The library is compiled for Java 8 with Kotlin 1.9’s API, so an app on Kotlin 1.9 or later can use it.
  • Kotlin coroutines: the library’s one dependency is kotlinx-coroutines-android. Its calls are suspend functions and its state is StateFlows.
  • Your PurrCRM address, https://app.purrcrm.com, and your app’s key, from the App key card on Settings › your app › Developers › Install.
  • A backend that signs a short token for your signed-in users (Sign users in).
  • Firebase Cloud Messaging in your app, for pushes. The SDK brings no Firebase of its own.

The set-up guide walks through the whole thing, PurrCRM‘s side and your app’s. In the app:

  1. Install the library.
  2. Initialise it in your Application.
  3. Sign users in.
  4. Set up push.
  5. Turn on the setup check in a debug build: it checks each of these steps on the phone.
  6. Check it from PurrCRM: the setup checklist on the overview ticks Install the SDK in a build when the first request from your app arrives, and names the SDK it saw (“Android 0.5.0”). Settings › your app › Developers › Install › What your app sees shows what PurrCRM knows of your app.

Then add what you need: links, the messenger, the help center, in-app messages, events, preferences and test mode. API at a glance lists every class and call.