com.leanplum.utils.CTUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leanplum-core Show documentation
Show all versions of leanplum-core Show documentation
The Leanplum SDK messaging platform
The newest version!
package com.leanplum.utils
import android.annotation.SuppressLint
import com.clevertap.android.sdk.CleverTapAPI
import com.clevertap.android.sdk.task.CTExecutorFactory
import com.clevertap.android.sdk.task.Task
object CTUtils {
@SuppressLint("RestrictedApi")
fun ensureLocalDataStoreValue(key: String, cleverTapApi: CleverTapAPI) {
val value = cleverTapApi.coreState.localDataStore.getProfileProperty(key)
if (value == null) {
cleverTapApi.coreState.localDataStore.updateProfileFields(mapOf(key to ""))
}
}
@SuppressLint("RestrictedApi")
fun addMultiValueForKey(key: String, value: String, cleverTapApi: CleverTapAPI) {
CTExecutorFactory
.executors(cleverTapApi.coreState.config)
.postAsyncSafelyTask>()
.execute("CTUtils") {
ensureLocalDataStoreValue(key, cleverTapApi)
cleverTapApi.addMultiValueForKey(key, value)
null
}
}
}