Документация для версии v75
Публичный API SDK
default export AltcraftSDK
AltcraftSDK
// Инициализация SDK и установка конфигурации
├─ function initialize(config: AltcraftConfig): Promise<void>
// Полная очистка данных SDK
├─ function clear(): Promise<void>
// Запрос разрешений на уведомления (платформозависимо)
├─ function requestNotificationPermission(): void
// Подписка на push (fire-and-forget)
├─ function pushSubscribe(
│ sync?: boolean | null,
│ profileFields?: Record<string, unknown> | null,
│ customFields?: Record<string, unknown> | null,
│ cats?: CategoryData[] | null,
│ replace?: boolean | null,
│ skipTriggers?: boolean | null
│ ): void
├─ function pushSuspend(...): void
└─ function pushUnSubscribe(...): void
// Статусы подписки (async)
├─ function unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>
├─ function getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>
├─ function getStatusOfLatestSubscriptionForProvider(provider?: string | null): Promise<ResponseWithHttpCode | null>
└─ function getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>
// События SDK (один подписчик на сторо не JS)
├─ function subscribeToEvents(handler: (event: SdkEvent) => void): void
└─ function unsubscribeFromEvent(): void
// Отправка мобильных событий
└─ function mobileEvent(
sid: string,
eventName: string,
sendMessageId?: string | null,
payload?: Record<string, unknown> | null,
matching?: Record<string, unknown> | null,
matchingType?: string | null,
profileFields?: Record<string, unknown> | null,
utm?: UTM | null
): void
// Токен push-провайдера
├─ function setPushToken(provider: string, token: string | null): Promise<void>
└─ function getPushToken(): Promise<TokenData | null>
// Android: входящий push payload в SDK
└─ function takePush(message: Record<string, string>): void
// Ручная регистрация push-событий (delivery/open) на стороне RN
├─ function deliveryEvent(message?: Record<string, string> | null, messageUID?: string | null): void
└─ function openEvent(message?: Record<string, string> | null, messageUID?: string | null): void
// iOS: запись значения в UserDefaults / App Group
└─ function setUserDefaultsValue(suiteName: string | null, key: string, value: unknown): void
Event Classes
SdkEvent
// Универсальное событие SDK, доставляется в JS через NativeEventEmitter.
function: string
code: number | null
message: string
type: 'event' | 'error' | 'retryError'
value?: Record<string, unknown> | null
Exported Types
// Категория подписки
export type CategoryData = {
name?: string | null;
title?: string | null;
steady?: boolean | null;
active?: boolean | null;
};
// Токен push-провайдера устройства
export type TokenData = {
provider: string | null;
token: string | null;
};
// Метаданные приложения
export type AppInfo = {
appID: string;
appIID: string;
appVer: string;
};
// Ответ API вместе с HTTP-кодом
export type ResponseWithHttpCode = {
httpCode: number | null;
response: Response | null;
};
export type Response = {
error?: number | null;
errorText?: string | null;
profile?: ProfileData | null;
};
export type ProfileData = {
id?: string | null;
status?: string | null;
isTest?: boolean | null;
subscription?: SubscriptionData | null;
};
export type SubscriptionData = {
subscriptionId?: string | null;
hashId?: string | null;
provider?: string | null;
status?: string | null;
fields?: { [key: string]: string } | null;
cats?: CategoryData[] | null;
};
// Контейнер UTM-параметров
export type UTM = {
campaign?: string | null;
content?: string | null;
keyword?: string | null;
medium?: string | null;
source?: string | null;
temp?: string | null;
};
AltcraftConfig
export type AltcraftConfig = {
apiUrl: string;
rToken?: string | null;
appInfo?: AppInfo | null;
providerPriorityList?: string[] | null;
enableLogging?: boolean | null;
// -------- ANDROID-ONLY --------
android_icon?: number | null;
android_usingService?: boolean | null;
android_serviceMessage?: string | null;
android_pushReceiverModules?: string[] | null;
android_pushChannelName?: string | null;
android_pushChannelDescription?: string | null;
};