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"))
Every operation
sovaria.api.call(method, path, …) reaches every Sovaria operation, generated from the same description as the other SDKs. Ergonomic wrappers: auth, db, files, functions, realtime.
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).
Something unclear or missing on this page?Tell us