Skip to main content

Contacts SDK

SDK for backing up and syncing Cloudike contacts.

Applies to Contacts SDK 5.5.2+

Installation

Declare Cloudike's private Maven repository in your project's settings.gradle.kts (artifactory_username/artifactory_password are credentials provided by Cloudike, set in your own gradle.properties):

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://rt.cloudike.com/artifactory/libs-release-local")
credentials {
username = settings.extra.properties["artifactory_username"].toString()
password = settings.extra.properties["artifactory_password"].toString()
}
}
}
}

Add contacts and its required core dependency to your app module's build.gradle.kts and sync the project:

dependencies {
implementation("com.cloudike.sdk:contacts:<version>")
implementation("com.cloudike.sdk:core:<version>")
}

Backing up contacts requires the READ_CONTACTS runtime permission to be granted first.

Initialization

import com.cloudike.sdk.contacts.ContactsManager
import com.cloudike.sdk.core.CoreManager
import com.cloudike.sdk.core.competition.CompetitionMode
import kotlinx.coroutines.runBlocking

val coreContext = CoreManager.build(applicationContext)

runBlocking {
coreContext.sessionManager.start(
reset = false,
baseUrl = "https://your-backend.example.com/", // your Cloudike backend endpoint
accessToken = accessToken, // from your sign-in flow
userId = userId, // from your sign-in flow
userAgent = "YourApp/1.0",
)
}

val contactsManager = ContactsManager.build(
coreContext = coreContext,
competitionMode = CompetitionMode.INTEGRATION,
competitorPackageName = "com.example.yourapp", // your own app's package name
canScheduleBackup = true, // enable periodic automatic backup
allowNetworkUsageInRoaming = false, // pick per your own data-usage policy
)

Builds the shared CoreContext, starts the user session on it, then builds ContactsManager on the same CoreContext. baseUrl/accessToken/userId/userAgent come from your own sign-in flow — the values shown are placeholders.

First API Call

import com.cloudike.sdk.contacts.backup.BackupState
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking

val result = runBlocking {
contactsManager.backup.backup()
contactsManager.backup.state.first { it is BackupState.Succeeded || it is BackupState.Failed }
}
println("Backup finished: $result")

Starts a contacts backup and waits for it to reach a terminal state — Succeeded or Failed(throwable) — confirming Contacts SDK can read and upload the device's contacts.