Android quickstart (Kotlin)
Add Sovaria to an Android app: install with Gradle, connect, sign in, read data, and keep the session in the Keystore.
Install
implementation("in.sovaria:sovaria:1.0.0")Register your app
Console › Authentication › Mobile › Apps: add the Android package name (
applicationId) and signing-certificate SHA-256 (from./gradlew signingReport), and a redirect URI such ascom.example.app://auth-callback.Connect
import `in`.sovaria.* val sovaria = Sovaria.initialize( url = "https://<ref>.sovarias.in", // Project settings › API anonKey = "svr_anon_…", // public; safe to ship in the app storage = KeystoreStore(context), // EncryptedSharedPreferences (see below) device = SovariaDevice(id = deviceId, platform = "android", name = deviceName), )Keep the session in the Keystore
class KeystoreStore(context: Context) : SessionStorage { // back with EncryptedSharedPreferences override suspend fun read(key: String): String? { /* … */ return null } override suspend fun write(key: String, value: String) { /* … */ } override suspend fun delete(key: String) { /* … */ } }Sign in and use data
sovaria.auth.signInWithPassword("a@b.co", password) val todos = sovaria.db.select("todos", where = mapOf("done" to false), orderBy = "created_at", limit = 20) sovaria.files.upload("avatars", "${sovaria.auth.currentSession?.userId}/me.png", bytes, contentType = "image/png") val channel = sovaria.realtime.channel("room:42", onMessage = { println(it) }) channel.send(mapOf("text" to "hi"))
#Deep links, push and attestation
// Provider sign-in, magic links, email confirmations (PKCE-bound when the link opens the app)
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
lifecycleScope.launch { sovaria.auth.handleDeepLink(intent.data.toString())?.let { if (it.type == "recovery") showNewPassword(it.token!!) } }
}
// Push: the FCM token
override fun onNewToken(token: String) { scope.launch { sovaria.push.register(token, platform = "android", provider = "fcm") } }
// App attestation: your Play Integrity provider in release builds, a debug token on emulators
val sovaria = Sovaria(url, anonKey, attestation = if (BuildConfig.DEBUG) DebugAttestationProvider(debugToken)
else PlayIntegrityProvider(packageName) { hash -> prepared.request(StandardIntegrityTokenRequest.builder().setRequestHash(hash).build()).await().token() })#Every operation
sovaria.api.<module>.<method>(…) exposes every Sovaria operation, generated from the same description as the JavaScript, Python, Dart and Swift SDKs (a golden-request test checks they send identical requests); sovaria.api.call(method, path, …) reaches any path. Wrappers: auth (with handleDeepLink), db, collections, files, functions, realtime, push, crashes, simulate, and enableOffline().
Realtime channels report CONNECTING, LIVE, RECONNECTING and CLOSED, as in the other SDKs. PlayIntegrityProvider is a few lines in your app (the SDK has no Google Play dependency); the AttestationProvider KDoc has a complete one.
Errors are SovariaException with status, code and a plain message. Coroutines + java.net.http; needs JDK 11+ (Android 8+/API 26+; on older Android, supply your own transport).