Skip to main content
Documentation for version v73

Public SDK API

object AltcraftSDK
AltcraftSDK
// SDK initialization and configuration setup
├─ fun initialization(context: Context, configuration: AltcraftConfiguration, complete: ((Result<Unit>) -> Unit)? = null): Unit
// Full cleanup of SDK data (DB, SP, background tasks)
├─ fun clear(context: Context, onComplete: (() -> Unit)? = null): Unit
// Register a JWT provider
├─ fun setJWTProvider(provider: JWTInterface?): Unit
// Allow push-module reinitialization in the current session
├─ fun reinitializePushModuleInThisSession(): Unit
// Base Altcraft push receiver (can be overridden)
├─ open class PushReceiver
// Handle incoming push message
│ ├─ open fun pushHandler(context: Context, message: Map<String, String>): Unit
// Entry point for delivering push messages to the SDK
│ └─ companion object
│ └─ fun takePush(context: Context, message: Map<String, String>): Unit
// Public subscription functions
├─ val pushSubscriptionFunctions: PublicPushSubscriptionFunctions
// Subscribe to push notifications (status = SUBSCRIBED)
│ ├─ fun pushSubscribe(
│ │ context: Context,
│ │ sync: Boolean = true,
│ │ profileFields: Map<String, Any?>? = null,
│ │ customFields: Map<String, Any?>? = null,
│ │ cats: List<DataClasses.CategoryData>? = null,
│ │ replace: Boolean? = null,
│ │ skipTriggers: Boolean? = null
│ │ ): Unit
// Suspend push notifications (status = SUSPENDED)
│ ├─ fun pushSuspend(...): Unit
// Unsubscribe from push notifications (status = UNSUBSCRIBED)
│ ├─ fun pushUnSubscribe(...): Unit
// Change subscription from suspended to subscribed for the one in JWT; others with this token switch to suspended
│ ├─ suspend fun unSuspendPushSubscription(context: Context): DataClasses.ResponseWithHttpCode?
// Status of the latest profile subscription
│ ├─ suspend fun getStatusOfLatestSubscription(context: Context): DataClasses.ResponseWithHttpCode?
// Status of latest subscription for a specific push provider
│ ├─ suspend fun getStatusOfLatestSubscriptionForProvider(context: Context, provider: String? = null): DataClasses.ResponseWithHttpCode?
// Status of subscription with current device token
│ ├─ suspend fun getStatusForCurrentSubscription(context: Context): DataClasses.ResponseWithHttpCode?
// Functional profile field (set/incr/…)
│ └─ fun actionField(key: String): ActionFieldBuilder
// Token management functions
├─ val pushTokenFunctions: PublicPushTokenFunctions
// Manually save provider token (onNewToken)
│ ├─ fun setPushToken(context: Context, provider: String, token: String): Unit
// Get current device push token
│ ├─ suspend fun getPushToken(context: Context): DataClasses.TokenData?
// Register FCM provider
│ ├─ fun setFCMTokenProvider(provider: FCMInterface?): Unit
// Register HMS provider
│ ├─ fun setHMSTokenProvider(provider: HMSInterface?): Unit
// Register RuStore provider
│ ├─ fun setRuStoreTokenProvider(provider: RustoreInterface?): Unit
// Delete provider device token
│ ├─ suspend fun deleteDeviceToken(context: Context, provider: String, complete: () -> Unit): Unit
// Forced token update (delete → refresh)
│ ├─ fun forcedTokenUpdate(context: Context, complete: () -> Unit): Unit
// Change provider priority list and update token
│ └─ suspend fun changePushProviderPriorityList(context: Context, priorityList: List<String>): Unit
// Push event tracking functions
├─ val pushEventFunction: PublicPushEventFunctions
// Track delivery (delivery event)
│ ├─ fun deliveryEvent(context: Context, message: Map<String, String>? = null, uid: String? = null): Unit
// Track open (open event)
│ └─ fun openEvent(context: Context, message: Map<String, String>? = null, uid: String? = null): Unit
// SDK events (single subscriber)
└─ val eventSDKFunctions: Events
├─ fun subscribe(newSubscriber: (DataClasses.Event) -> Unit): Unit
└─ fun unsubscribe(): Unit

class AltcraftConfiguration
com.altcraft.sdk.config
└─ class AltcraftConfiguration private constructor(...)
// SDK configuration class:
// API URL, rToken, app info, foreground service flag,
// push channel settings, receiver modules, provider priority.

├─ class Builder(
│ apiUrl: String,
│ icon: Int? = null,
│ rToken: String? = null,
│ usingService: Boolean = false,
│ serviceMessage: String? = null,
│ appInfo: DataClasses.AppInfo? = null,
│ providerPriorityList: List<String>? = null,
│ pushReceiverModules: List<String>? = null,
│ pushChannelName: String? = null,
│ pushChannelDescription: String? = null
)
│ └─ fun build(): AltcraftConfiguration

├─ fun getApiUrl(): String
├─ fun getIcon(): Int?
├─ fun getRToken(): String?
├─ fun getUsingService(): Boolean
├─ fun getServiceMessage(): String?
├─ fun getAppInfo(): DataClasses.AppInfo?
├─ fun getProviderPriorityList(): List<String>?
├─ fun getPushReceiverModules(): List<String>?
├─ fun getPushChannelName(): String?
└─ fun getPushChannelDescription(): String?

Event Classes
Event
function: String
eventCode: Int?
eventMessage: String?
eventValue: Map<String, Any?>?
date: Date

Error
function: String
eventCode: Int?
eventMessage: String?
eventValue: Map<String, Any?>?
date: Date

RetryError
function: String
eventCode: Int?
eventMessage: String?
eventValue: Map<String, Any?>?
date: Date

Data Classes
data class TokenData(
provider: String,
token: String
)

data class AppInfo(
appID: String,
appIID: String,
appVer: String
)
asMap(): Map<String, String>

data class ResponseWithHttpCode(
httpCode: Int?,
response: Response?
)

data class Response(
error: Int? = null,
@SerialName("error_text") errorText: String? = null,
profile: ProfileData? = null
)

data class ProfileData(
id: String? = null,
status: String? = null,
@SerialName("is_test") isTest: Boolean? = null,
subscription: SubscriptionData? = null
)

data class SubscriptionData(
@SerialName("subscription_id") subscriptionId: String? = null,
@SerialName("hash_id") hashId: String? = null,
provider: String? = null,
status: String? = null,
fields: Map<String, JsonElement>? = null,
cats: List<CategoryData>? = null
)

data class CategoryData(
name: String?,
title: String? = null,
steady: Boolean? = null,
active: Boolean?
)

data class EmailSubscription(...)

data class SmsSubscription(...)

data class PushSubscription(...)

data class CcDataSubscription(...)

data class UTM(
campaign: String? = null,
content: String? = null,
keyword: String? = null,
medium: String? = null,
source: String? = null,
temp: String? = null
)

Interfaces

JWTInterface

fun getJWT(): String?

FCMInterface

suspend fun getToken(): String?
suspend fun deleteToken(completion: (Boolean) -> Unit)

HMSInterface

suspend fun getToken(context: Context): String?
suspend fun deleteToken(context: Context, complete: (Boolean) -> Unit)

RuStoreInterface

suspend fun getToken(): String?
suspend fun deleteToken(complete: (Boolean) -> Unit)

Subscription (sealed interface)

val resourceId: Int
val status: String?
val priority: Int?
val customFields: Map<String, Any?>?
val cats: List<String>?
val channel: String