Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guide iconUser guide
Developer guide iconDeveloper guide
Admin guide iconAdmin guide
English
  • Русский
  • English
Login
    User API documentationAPI interactionMatching
      Profilesarrow
    • Import profileUpdate profileImport multiple profilesUpdate multiple profilesAdd multiple profilesAdd profile to databaseQuick profile importImport profile to RabbitMQGet profile dataUploading profiles to a fileSuspend all database profilesUnsuspend all profiles in a databaseDelete profileSubscription fields functional updateDatabase fields functional updateMerging multiple profilesUnsubscribe profile from resourceProfile splitting
        Subscriptionsarrow
      • Add or edit subscriptionGet all profile subscriptionsGet all subscriptions from multiple profilesGet profile subscriptionDelete profile subscriptionRestore deleted subscriptionSuspend all subscriptionsUnsuspend all suspended subscriptions
        Action historyarrow
      • Get profile action historyGet multiple profiles action history
        Profile relationsarrow
      • Attach relationDetach relationModify relation propertiesOverwrite relation propertiesGet profile relations infoGet profile relations info
      Get data for multiple profiles
      Databasesarrow
    • Get database statisticsUpdate statistics on databaseGet database listGet database informationGet database fieldsDatabase wipe
      Resourcesarrow
    • Get resource statisticsUpdate statistics on resourceGet resources listGet resource informationGet resource subscription fields
      Segmentsarrow
    • Get statistics on resourceUpdate statistics on segmentAdd or remove profileGet profile data in a static segmentCreate segmentUpdate segmentGet segment informationGet segments listDelete segment
      Suppression listsarrow
    • Create suppression listUpdate suppression listGet suppression list infoGet the list of suppression listsDelete suppression listUpload suppression list data to file
        Suppression list actionsarrow
      • Check if email is suppressedAdd email to suppression listAdd multiple emails to suppression listRemove email from suppression listRemove all emails from suppression listCheck if domain is suppressedAdd domain to suppression listAdd multiple domains to suppression listRemove domain from suppression listRemove all domains from suppression listCheck if phone number is suppressedAdd phone number to suppression listAdd multiple phones to suppression listRemove phone number from suppression listRemove all phone numbers from suppression list
      Templates and fragmentsarrow
    • Get templates listGet template infoDelete templateAdd templateUpdate templateChannel object
      Campaignsarrow
    • Get campaign informationGet campaign listActivate campaignComplete campaignDeactivate campaignGet campaign status
      Mailingsarrow
    • Activate mailingDeactivate mailingGet mailing listGet mailing informationGet mailing logClone mailingDelete mailingGet mailing status
        Broadcast mailingsarrow
      • Get broadcasts listGet broadcast informationCreate broadcast mailingUpdate broadcast mailingLaunch a broadcast mailing
        Regular mailingsarrow
      • Get regular mailings listGet regular mailing informationCreate regular mailingUpdate regular mailingLaunch a regular mailing
        Trigger mailingsarrow
      • Get trigger mailings listGet trigger mailing informationCreate trigger mailingUpdate trigger mailingTrigger launch (API call)Profile import + trigger mailing launchTask for bulk trigger launchTask for bulk profiles import + trigger launchBulk trigger launchBulk profiles import + trigger mailing launchClone a trigger mailingData array
      Automation scenariosarrow
    • Engage profile in scenarioImport and engage profile in scenarioBatch import and engage profiles in a scenarioTask for batch import and engaging profiles in the scenarioGet scenarios listActivate scenarioDeactivate scenario
      Loyalty Programsarrow
    • Get profile tier in a loyalty programExport points transactionsExpiring points for a periodGet profile account transactionsGet trigger promotions listAccrue points to a memberRedeem member pointsCommit temporary transactionPreliminary Order CalculationOrder ConfirmationRoll back temporary transactionCancel points transactionGet points account balanceRegister member in a loyalty programRemove member from loyalty program
      Promo codesarrow
    • Import promo codesGet promo code informationActivate promo codeUpdate promo codeAttach promo codeDetach promo codeGet all promo codes
      Goalsarrow
    • Goals and goal values registration
      Application push notificationsarrow
    • Processing and adding a subscriptionAdd app push events
      Marketarrow
      • Market objectsarrow
      • Order data objectProduct data objectSKU data objectCategories arrayCustom fields array
        Ordersarrow
      • Import order and item statusesGet orders listDelete orderGet order statusUpdate order line status
        Products and SKUarrow
      • Import products, SKUs and categoriesImport SKUs and categoriesGet products listGet SKUs listDelete productsDelete SKU
      Analytic reportsarrow
    • Get summary reportGet soft bounces reportGet undeliveries report
      SendersDevarrow
    • Get senders list
        Virtual senders (Smart accounts only)arrow
      • Get virtual senders listGet virtual sender informationClone virtual senderCreate virtual senderUpdate virtual senderDelete virtual sender
      External datatables queriesarrow
      • Segmentation queriesarrow
      • Add segmentation queryUpdate segmentation queryGet segmentation query informationGet segmentation queries listDelete segmentation query
        Template queriesarrow
      • Add template queryUpdate template queryGet template query informationGet template queries listDelete template query
      Objectsarrow
    • AKMTA objectContent objectEmail rule objectFile objectProfile data objectSMS rule objectSender objectSender typesStart schedule objectSubscription objectTrigger types
      Miscellaneousarrow
    • Upload fileGet message web versionPush providersDeduplication of requestsHow to send API request with RabbitMQList of gender identificationsObtain valid values for fields: browsers, devices, tz, oses, languages
    Importing the API collection in PostmanList of API endpoints
      SDKarrow
      • mSDKarrow
        • Androidarrow
        • Quick StartSDK FunctionalitySDK ConfigurationPublic SDK API
            Provider configuration androidarrow
          • Firebase Cloud MessagingHuawei Mobile ServicesRuStore
          iOSarrow
        • Quick StartSDK FunctionalitySDK ConfigurationPublic SDK API
            Provider configurationarrow
          • Apple Push Notification ServiceFirebase Cloud MessagingHuawei Mobile Services
          React Native (Android/iOS)arrow
        • Quick StartSDK ConfigurationSDK FunctionalityPublic SDK APIProvider setup
        Managing JWT and Role Token
  • SDK
  • mSDK
  • iOS
  • Quick Start

Quick Start

This article provides a rapid integration example of Altcraft mSDK with Apple Push Notification System (APNS) and Firebase Cloud Messaging (FCM). After completing the steps, your app will be able to receive Altcraft push notifications.

To use Huawei Mobile Services, add the corresponding SDKs to the project and implement their interfaces using the same approach shown for APNS and FCM.

Step 0. Prerequisites​

  • APNS access obtained on the website;
  • The app is configured in a Firebase project, and GoogleServiceInfo.plist is downloaded.

Step 1. Altcraft SDK integration into the app​

Add packages from repositories using Swift Package Manager:

  • Repository Altcraft SDK;
  • Repository Firebase.

Step 2. Add GoogleServiceInfo to the app​

Add GoogleServiceInfo.plist to your app folder:

Step 3. App preparation​

Configure the following app target settings:

  • General:

    • Ensure the Altcraft library is added under Frameworks, Libraries, and Embedded Content of the app target:
    * Ensure the **FirebaseMessaging** library is added under **Frameworks, Libraries, and Embedded Content** of the app target:
  • Signing & Capabilities:

    • PushNotifications;
    • AppGroups — specify a group identifier (adding an App Group identifier is required for data exchange with the Notification Service Extension);
    • Background Modes — enable Background fetch, Remote notification, Background processing.
  • Info:

    • Add the following keys and values:
KeyTypeValue
Permitted background task scheduler identifiersArray"lib.Altcraft.bgTask.systemControl"
FirebaseAppDelegateProxyEnabledBooleanNO

The first key registers a bgTask that retries failed server requests in background mode. The second key disables the automatic method swizzling of AppDelegate that Firebase Messaging performs by default.

Step 4. JWTInterface realization​

Implement the SDK protocol for providing a JWT token. Create a class that implements JWTInterface and override getJWT():

import Altcraft

class JWTProvider: JWTInterface {
func getToken() -> String? {
// your code returning JWT
}
}
Note

getJWT() is a synchronous function. The SDK execution thread will be paused until JWT is obtained. It’s recommended that getJWT() returns immediately from cache (in-memory, SharedPreferences or EncryptedSharedPreferences) to speed up requests. Ideally, prepare a fresh JWT as early as possible (at app start) and store it in cache so the token is available without delays. Returning nil is acceptable if no value is available.

Step 5. FCMInterface realization​

Implement the SDK protocol for providing and deleting the FCM token. Create a class that implements FCMInterface and override getToken(), deleteToken().

import FirebaseMessaging
import Altcraft

class FCMProvider: FCMInterface {

/// Returns the current FCM token
func getToken(completion: @escaping (String?) -> Void) {

/// APNs token retrieved from UserDefaults
let apnsToken = getAPNsTokenDataFromUserDefaults()

/// set the APNs token for FCM before requesting the FCM token
Messaging.messaging().apnsToken = apnsToken

/// request the FCM token
Messaging.messaging().token { token, error in
if error != nil {
completion(nil)
} else {
completion(token)
}
}
}

/// Deletes the current FCM token
func deleteToken(completion: @escaping (Bool) -> Void) {
Messaging.messaging().deleteToken { error in
if error != nil {
completion(false)
} else {
completion(true)
}
}
}
}

Step 6. APNSInterface realization​

Implement the SDK protocol for providing the APNS token. Create a class that implements APNSInterface and override getToken():

import Altcraft

class APNSProvider: APNSInterface {
/// Retrieves the current APNs token from local storage
func getToken(completion: @escaping (String?) -> Void) {
let token = getAPNsTokenFromUserDefault() // pass the APNs token
completion(token)
}
}

Step 7. Configure Altcraft SDK and Firebase SDK in AppDelegate​

Altcraft SDK:

- pass the `AppGroups` identifier to Altcraft SDK;
- register Altcraft `backgroundTasks`;
- set JWT, APNS, and FCM providers;
- register with the notification center.

Firebase SDK:

  • apply the configuration;
Example of correct Altcraft SDK and Firebase SDK setup in AppDelegate
class AppDelegate: UIResponder, UIApplicationDelegate,  UNUserNotificationCenterDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Firebase SDK configuration
FirebaseApp.configure()

// Altcraft SDK
/// set App Group identifier
AltcraftSDK.shared.setAppGroup(groupName: "group.your_company.name")
/// register BGTask
AltcraftSDK.shared.backgroundTasks.registerBackgroundTask()
/// set JWTProvider
AltcraftSDK.shared.setJWTProvider(provider: JWTProvider())
/// set APNSProvider
AltcraftSDK.shared.pushTokenFunctions.setAPNSTokenProvider(APNSProvider())
/// set FCMProvider
AltcraftSDK.shared.pushTokenFunctions.setFCMTokenProvider(FCMProvider())
/// register with notification center
AltcraftSDK.shared.notificationManager.registerForPushNotifications(for: application)

return true
}

func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken apnsToken: Data
) {
// save APNs token in UserDefaults
setAPNsTokenInUserDefault(apnsToken)
}
}
  • set the delegate;
  • pass the APNS token to Firebase in AppDelegate.application(_:didFinishLaunchingWithOptions:). This ensures correct Firebase initialization and FCM token availability in background mode, for example during a BGTask. Since the APNS token is not available in AppDelegate.application(_:didFinishLaunchingWithOptions:), use the saved value (e.g., in UserDefaults).

Step 8. Create a Notification Service Extension​

Create a Notification Service Extension:

  • File — New — Target — Notification Service Extension;
  • Choose a Product Name for the extension target;
  • Activate it.

In the Notification Service Extension:

  • General:

    • Set Minimum Deployments — the Xcode build setting that defines the minimum OS version supported by the Notification Service Extension;
    • Add the Altcraft library under Frameworks, Libraries and Embedded Content.
  • Signing & Capabilities:

    • AppGroups — specify the AppGroup identifier.

Then configure the SDK inside your UNNotificationServiceExtension. Replace the entire automatically generated NSE code with the example below:

Example implementation of UNNotificationServiceExtension
import Altcraft
import UserNotifications

class NotificationService: UNNotificationServiceExtension {

/// - important! Set your App Group identifier.
let appGroupID = "group.your.id"

/// - important! Set the provider to JWT if you are using JWT authentication.
let jwtProvider = JWTProvider()

override func didReceive(
_ request: UNNotificationRequest,
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
) {

AltcraftNSE.shared.setAppGroup(groupName: appGroupID)
AltcraftNSE.shared.setJWTProvider(provider: jwtProvider)

contentHandler(request.content)

if AltcraftNSE.shared.isAltcraftPush(request) {
AltcraftNSE.shared.handleNotificationRequest(
request: request,
contentHandler: contentHandler
)
} else {
contentHandler(request.content)
}
}

override func serviceExtensionTimeWillExpire() {
AltcraftNSE.shared.serviceExtensionTimeWillExpire()
}
}
Note

If you are not using JWT authentication, remove the call to AltcraftSDK.shared.setJWTProvider(provider: jwtProvider).

Step 9. SDK initialization​

Create a configuration variable and initialize using initialization(), choosing ios-firebase as the preferred provider:

let config = AltcraftConfiguration.Builder()
.setApiUrl("your_api_url")
.setProviderPriorityList([Constants.ProviderName.firebase])
.build()

AltcraftSDK.shared.initialization(configuration: config)

In this example, ios-firebase is set as the preferred provider. You can also set APNS as the preferred provider:

let config = AltcraftConfiguration.Builder()
.setApiUrl("your_api_url")
.setProviderPriorityList([Constants.ProviderName.apns])
.build()

AltcraftSDK.shared.initialization(configuration: config)

You may omit setProviderPriorityList; the default priority will be used — ios-apns -> ios-firebase -> ios-huawei:

let config = AltcraftConfiguration.Builder()
.setApiUrl("your_api_url")
.build()

AltcraftSDK.shared.initialization(configuration: config)

Step 10. Subscribe to push notifications​

Subscribe to push notifications using pushSubscribe() and pass the required parameters:

AltcraftSDK.shared.pushSubscriptionFunctions.pushSubscribe(
profileFields: ["_fname": "user_first_name", "_lname": "user_last_name"]
)
Last updated on Mar 10, 2026
Previous
iOS
Next
SDK Functionality
  • Step 0. Prerequisites
  • Step 1. Altcraft SDK integration into the app
  • Step 2. Add GoogleServiceInfo to the app
  • Step 3. App preparation
  • Step 4. JWTInterface realization
  • Step 5. FCMInterface realization
  • Step 6. APNSInterface realization
  • Step 7. Configure Altcraft SDK and Firebase SDK in AppDelegate
  • Step 8. Create a Notification Service Extension
  • Step 9. SDK initialization
  • Step 10. Subscribe to push notifications
© 2015 - 2026 Altcraft, LLC. All rights reserved.