Skip to main content

Getting Started

Before You Begin#

This SDK is stored in the private maven repo and developed for use with the Cloudike Backend. If you need access, please Contacts Us.

Requirements#

Installation#

To enable library in your app, you should add a link to our private repository in the application-level Gradle file (usually app / build.gradle). Then, add a dependency for the libraries cloudikecleaner и cloudikelog as shown below:

// Add these lines to your project level gradle filerepositories {    maven {        url "https://rt.cloudike.com/artifactory/libs-release-local"        credentials {            username = "${artifactory_username}"            password = "${artifactory_password}"        }    }}
// Add these dependencies to your application level gradle filedependencies {    implementation 'com.cloudike.cloudikecleaner:cloudikecleaner:4.2.3'    implementation 'com.cloudike.cloudikephotos:cloudikephotos:2.9.15'    implementation 'com.cloudike.cloudikelog:cloudikelog:1.2.7'}

Initialization#

Initialization is performed in two stages.

Stage 1. Initialize library#

The best method for the first step is the method Application.onCreate(). The first step is to initialize the dependencies of the cleaner library in the specified sequence.

override fun onCreate() {    super.onCreate()        // ...        // Initialize logger first because Cleaner SDK and Photo SDK uses it    Logger.init(applicationContext)    Logger.setDebugMode(true)
    // Optionally    // initRxErrorHandler()      // Then, initialize the photo library as the Cleaner SDK uses it    PhotoManager.initInstance(        context = applicationContext,        competitionMode = PhotoManager.CompetitionMode.INTEGRATION,        competitorPackageName = "com.cloudike.NO_COMPETITOR_APP",        enablePeriodicScans = true    )
    // Initialize cleaner library    CleanerManagerFactory.initAndGet(applicationContext)        // ...}

If you need to use the custom parameters SSL Socket Factory and Trust Manager, use the following guide.

Stage 2. Preparation for work.#

After user has logged in, it is necessary to call PhotoManager.prepareToWork() and then CleanerManagerFactory.cleanerManager.prepareToWork():

PhotoManager.prepareToWork(    baseUrl = "Base URL of the backend",    token = "Mountbit-Auth token received after user login",    profileId = "User profile id",    userAgent = "User agent string",    deviceId = "Unique device id")
CleanerManagerFactory.cleanerManager.prepareToWork(    token = "Mountbit-Auth token received after user login",    baseUrl = "Base URL of the backend",    profileId = "User profile id",    userAgent = "User agent string")

Optionally: initialization of the RxJava2 error handler#

To log errors that occur in RxJava2, using in Photo SDK, it is advisable to initialize the handler:

private fun initRxErrorHandler() {    RxJavaPlugins.setErrorHandler(Consumer { exception ->        var e: Throwable? = exception        if (e is UndeliverableException) {            e = e.cause        }        if (e is OnErrorNotImplementedException) {            // error received by observer that does not provide onError handler            if (e.cause != null) {                e = e.cause            }        }        if (e is IOException || e is SocketException) {            // fine, irrelevant network problem or API that throws on cancellation            Logger.main().i("RxErrorHandler", "Exception caught", e)            return@Consumer        }        if (e is InterruptedException) {            // fine, some blocking code was interrupted by a dispose call            Logger.main().i("RxErrorHandler", "Exception caught", e)            return@Consumer        }        if (e is NullPointerException                || e is IllegalArgumentException                || e is UnsupportedOperationException) {            // that's likely a bug in the application            Logger.main().e("RxErrorHandler", "Exception caught", e)            Thread.currentThread().uncaughtExceptionHandler                    .uncaughtException(Thread.currentThread(), e)            return@Consumer        }        if (e is IllegalStateException) {            Logger.main().e("RxErrorHandler", "Exception caught", e)            // that's a bug in RxJava or in a custom operator            Thread.currentThread().uncaughtExceptionHandler                   .uncaughtException(Thread.currentThread(), e)            return@Consumer        }        Logger.main().w("RxErrorHandler",             "Undeliverable exception received, not sure what to do", e)    })}

Dependencies#

Our SDK uses the following dependencies:

// Coroutinesimplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
// Retrofitimplementation 'com.squareup.retrofit2:retrofit:2.6.4'implementation 'com.squareup.retrofit2:converter-gson:2.6.4'implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.4'implementation 'com.squareup.okhttp3:okhttp:3.14.9'implementation 'com.squareup.okhttp3:logging-interceptor:3.14.9'
// ASD Technologiesimplementation "com.cloudike.cloudikelog:cloudikelog:1.2.5"