Android: add Appwin to your app

Learn how to add Appwin to your Android app with the Maven artifacts.

Before you start

Build your integration

Pick the products you want. The dependency list and the initialisation code follow your choice.

Build your integration

AppwinCore is always in - it carries the identity, the session and the network client. Pick what you add on top.

AppwinCore

Use a prompt

Dependencies

kotlin
dependencies {
    implementation("io.appwin:appwin-core:0.4.0")
    implementation("io.appwin:appwin-community:0.4.0")
}

Initialisation

kotlin
import io.appwin.core.AppwinCore
import io.appwin.community.AppwinCommunity

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        AppwinCore.configure(
            applicationContext,
            projectAppId = BuildConfig.APPWIN_APP_ID,
        )
    }
}

lifecycleScope.launch {
    AppwinCore.bootstrapSession()
    val community = AppwinCommunity.initialize()
}
  • Each initialize() answers rather than throwing. Gate your own entry point on the result - the SDK does not own your navigation, so it cannot hide your tab for you.

Keep the App ID out of your source with a buildConfigField:

kotlin
android {
    defaultConfig {
        buildConfigField("String", "APPWIN_APP_ID", "\"${property("appwinAppId")}\"")
    }
    buildFeatures { buildConfig = true }
}

Put it on screen

initialize() says whether a product may open. Where it goes is yours - the SDK does not own your navigation.

ArtifactWhat you place
appwin-communityCommunityView(), a composable
appwin-supportMessengerView()
appwin-notificationsNo UI - registerPushToken(...) at launch
appwin-analyticsNo UI - trackEvent(...)
kotlin
if (community is AppwinInitResult.Ready) {
    CommunityView()
}

A refused product logs loudly in a debug build, quietly in release, and falls back to a neutral view if you present it anyway. It never crashes, and it never silently does nothing.

Attach your user

Optional, and it is what makes a person the same in Community and in Support, and across their devices. The externalId is yours - the one from your database.

kotlin
AppwinCore.identify(user.id)
AppwinCore.bootstrapSession(externalId = user.id)

AppwinCore.signOut()   // on sign-out

identify alone is not enough: replaying the bootstrap is what mints a token carrying the new identity. Without it, the calls that follow stay on the anonymous session until the next launch.

Where to go next