Skip to main content
Documentation for version v73

Classes and Structures

Public classes

List of public SDK classes

class AltcraftSDK

AltcraftSDK
// Singleton — SDK entry point
├─ public static let shared: AltcraftSDK
// Initialize the SDK with a configuration (completion is invoked on main)
├─ public func initialization(configuration: AltcraftConfiguration?, completion: ((Bool) -> Void)? = nil): Void
// Set App Group and initialize Core Data for the shared container
├─ public func setAppGroup(groupName: String): Void
// Register a JWT provider for fetching tokens
├─ public func setJWTProvider(provider: JWTInterface): Void
// Full SDK reset (cache/DB/settings), then call completion
├─ public func clear(completion: (() -> Void)? = nil): Void
|
// SDK event stream (one active subscriber)
├─ public let eventSDKFunctions: SDKEvents
│ // Subscribe to SDK events (replaces the existing subscriber)
│ ├─ func subscribe(callback: @escaping (Event) -> Void): Void
│ // Unsubscribe from events (callback remains assigned, delivery stops)
│ ├─ func unsubscribe(): Void
│ // Event model (base type for all events/errors)
│ ├─ Event
│ │ // Base event model
│ │ id: UUID
│ │ function: String
│ │ message: String?
│ │ eventCode: Int?
│ │ value: [String: Any?]?
│ │ date: Date
│ │ // Initializer (normalizes function, filters nils in value)
│ │ init(function: String, message: String? = nil, eventCode: Int? = nil, value: [String: Any?]? = nil, date: Date = Date())
│ │ // Equality by unique id
│ │ static func ==(lhs: Event, rhs: Event) -> Bool
│ │ // Hash by id
│ │ func hash(into hasher: inout Hasher): Void
│ │
│ │ // Non-retryable errors (4xx class)
│ │ ErrorEvent : Event
│ │ init(function: String, message: String? = nil, eventCode: Int? = nil, value: [String: Any?]? = nil, date: Date = Date())
│ │
│ │ // Retryable errors (usually 5xx)
│ │ RetryEvent : ErrorEvent
│ │ init(function: String, message: String? = nil, eventCode: Int? = 0, value: [String: Any?]? = nil, date: Date = Date())
|
// Managing push tokens and providers (FCM/HMS/APNs)
├─ public let pushTokenFunction: PublicPushTokenFunctions
│ // Set the Firebase Cloud Messaging provider (nil — remove)
│ ├─ public func setFCMTokenProvider(_ provider: FCMInterface?): Void
│ // Set the Huawei Mobile Services provider (nil — remove)
│ ├─ public func setHMSTokenProvider(_ provider: HMSInterface?): Void
│ // Set the Apple Push Notification service provider (nil — remove)
│ ├─ public func setAPNSTokenProvider(_ provider: APNSInterface?): Void
│ // Asynchronously get the current push token (completion is optional)
│ ├─ public func getPushToken(completion: ((TokenData?) -> Void)? = nil): Void
│ // Manually save the token (String for FCM/HMS, Data for APNs); provider: "ios-firebase" | "ios-huawei" | "ios-apns"
│ ├─ public func setPushToken(provider: String, pushToken: Any?): Void
│ // Apply a new provider priority list and initiate token update
│ ├─ public func changePushProviderPriorityList(_ list: [String]): Void
│ // Delete the selected provider’s token and call completion
│ ├─ public func deleteDeviceToken(provider: String, completion: @escaping () -> Void): Void
│ // Force token update (determine provider → delete (except APNs) → request new)
│ └─ public func forcedTokenUpdate(completion: (() -> Void)? = nil): Void
|
// Managing push subscription (status changes, status requests)
├─ public let pushSubscriptionFunctions: PublicPushSubscriptionFunctions
│ // Subscribe (status = SUBSCRIBED)
│ ├─ public func pushSubscribe(
│ │ sync: Bool = true,
│ │ profileFields: [String: Any?]? = nil,
│ │ customFields: [String: Any?]? = nil,
│ │ cats: [CategoryData]? = nil,
│ │ replace: Bool? = nil,
│ │ skipTriggers: Bool? = nil
│ │ ): Void
│ // Unsubscribe (status = UNSUBSCRIBED)
│ ├─ public func pushUnSubscribe(
│ │ sync: Bool = true,
│ │ profileFields: [String: Any?]? = nil,
│ │ customFields: [String: Any?]? = nil,
│ │ cats: [CategoryData]? = nil,
│ │ replace: Bool? = nil,
│ │ skipTriggers: Bool? = nil
│ │ ): Void
│ // Suspend (status = SUSPENDED)
│ ├─ public func pushSuspend(
│ │ sync: Bool = true,
│ │ profileFields: [String: Any?]? = nil,
│ │ customFields: [String: Any?]? = nil,
│ │ cats: [CategoryData]? = nil,
│ │ replace: Bool? = nil,
│ │ skipTriggers: Bool? = nil
│ │ ): Void
│ // UnSuspend subscription (single request, no retries/persist)
│ ├─ public func unSuspendPushSubscription(
│ │ completion: @escaping (ResponseWithHttp?) -> Void
│ │ ): Void
│ // Status of the profile’s latest subscription
│ ├─ public func getStatusOfLatestSubscription(
│ │ completion: @escaping (ResponseWithHttp?) -> Void
│ │ ): Void
│ // Subscription status corresponding to the current token/provider
│ ├─ public func getStatusForCurrentSubscription(
│ │ completion: @escaping (ResponseWithHttp?) -> Void
│ │ ): Void
│ // Status of the latest subscription by provider (if nil — the current one is used)
│ └─ public func getStatusOfLatestSubscriptionForProvider(
│ │ provider: String? = nil,
│ │ completion: @escaping (ResponseWithHttp?) -> Void
│ │ ): Void
| // add a functional profile field (set/incr/...)
| └─ public func actionField(key: String) -> ActionFieldBuilder
|
// Manual sending of push events (delivery/open)
├─ public let pushEventFunctions: PublicPushEventFunctions
│ // Record Altcraft-push delivery (fires a delivery event)
│ ├─ public func deliveryEvent(from request: UNNotificationRequest): Void
│ // Record Altcraft-push open (fires an open event)
│ └─ public func openEvent(from request: UNNotificationRequest): Void
|
// Registration of periodic background tasks (BGAppRefreshTask)
├─ public let backgroundTasks: BackgroundTasks
│ // Register the task and schedule periodic runs (~every 3 hours)
│ └─ public func registerBackgroundTask(): Void
|
// In-app notification management (notification center delegate)
├─ public let notificationManager: NotificationManager
// Assign delegate, request permissions, and register for remote notifications; completion returns granted/error
├─ func registerForPushNotifications(for application: UIApplication, completion: ((_ granted: Bool, _ error: Error?) -> Void)? = nil): Void
// Foreground notification display (banner/alert + badge/sound)
├─ public func userNotificationCenter(
│ _ center: UNUserNotificationCenter,
│ willPresent notification: UNNotification,
│ withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
│ ): Void
// Handle user interaction (tap/actions), log open event
└─ public func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
): Void

class AltcraftPushReceiver

// Used in Notification Service Extension (NSE) — handling rich pushes (categories/buttons/media), with no dependencies on UIApplication
AltcraftPushReceiver
// Verify that the push is from Altcraft (by a marker in userInfo)
├─ public func isAltcraftPush(_ request: UNNotificationRequest) -> Bool
// Process the incoming request: create categories/buttons, attach media, record delivery, and return content to the NSE
├─ public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void): Void
// Return the "best available" content on NSE timeout
└─ public func serviceExtensionTimeWillExpire(): Void

class AltcraftConfiguration

AltcraftConfiguration
// Altcraft SDK configuration class.
// Stores the base API URL and optional parameters (rToken, AppInfo, providerPriorityList).
// Created only via Builder.

├─ public class Builder
│ // Builder for forming a validated configuration.
│ // Allows setting required and optional fields and building the configuration object.
│ // Builder constructor
│ ├─ public init(): Builder
│ // Set API URL (required parameter)
│ ├─ public func setApiUrl(_ url: String) -> Builder
│ // Set resource token (optional)
│ ├─ func setRToken(_ rToken: String?) -> Builder
│ // Set AppInfo metadata used in Firebase Analytics
│ ├─ public public func setAppInfo(_ info: AppInfo?) -> Builder
│ // Set push provider priority list (optional)
│ ├─ public func setProviderPriorityList(_ list: [String]?) -> Builder
│ // Build a valid configuration (nil if validation fails)
│ └─ public func build() -> AltcraftConfiguration?
// Access configuration parameters
├─ public func getApiUrl() -> String
├─ public func getRToken() -> String?
├─ public func getAppInfo() -> AppInfo?
└─ public func getProviderPriorityList() -> [String]?

Public structures

List of public SDK structures
TokenData
// Structure for storing a push token and the provider name (for UserDefaults).
provider: String // "ios-apns", "ios-firebase", "ios-huawei"
token: String

AppInfo
// Represents basic app metadata used in Firebase Analytics.
appID: String
appIID: String
appVer: String
├─ init(appID: String, appIID: String, appVer: String)

// API response wrapper with HTTP code.
ResponseWithHttp
httpCode: Int?
response: Response?

// Synchronous response for subscription change/status requests.
Response
error: Int?
errorText: String?
profile: ProfileData?

// User profile data.
ProfileData
id: String?
status: String?
isTest: Bool?
subscription: SubscriptionData?

// Current profile subscription.
SubscriptionData
subscriptionId: String?
hashId: String?
provider: String?
status: String?
fields: [String: JSONValue]?
cats: [CategoryData]?

// Subscription category description.
CategoryData
name: String?
title: String?
steady: Bool?
active: Bool?
├─ init(name: String?, title: String?, steady: Bool?, active: Bool?)

// Universal JSON value for arbitrary fields.
JSONValue (enum)
cases:
- string(String)
- number(Double)
- bool(Bool)
- object([String: JSONValue])
- array([JSONValue])
- null
// Conformance: Codable (custom encoding/decoding).