Android: add Appwin to your app
Learn how to add Appwin to your Android app with the Maven artifacts.
Before you start
- An app created in the dashboard
- Your App ID
- minSdk 24 or later, and Jetpack Compose
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.
Use a prompt
Dependencies
dependencies {
implementation("io.appwin:appwin-core:0.4.0")
implementation("io.appwin:appwin-community:0.4.0")
}
Initialisation
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:
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.
| Artifact | What you place |
|---|---|
appwin-community | CommunityView(), a composable |
appwin-support | MessengerView() |
appwin-notifications | No UI - registerPushToken(...) at launch |
appwin-analytics | No UI - trackEvent(...) |
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.
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.