Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.appstack.tech/llms.txt

Use this file to discover all available pages before exploring further.

Use Cursor, Claude Code, or another AI to help you integrate the Swift SDK.

CursorOpen in Cursor

Appstack ID and attribution params

After configure, you can read the Appstack user ID and the attribution map for partner integrations (for example Superwall, RevenueCat).
let appstackId = AppstackAttributionSdk.shared.getAppstackId()
let attributionParams = AppstackAttributionSdk.shared.getAttributionParams()
  • getAppstackId() — Appstack user identifier when a partner expects $appstackId or similar.
  • getAttributionParams() — Attribution payload (campaign, media source, click IDs, device identifiers where available) to forward to partners.

GitHub repository

Here, you will find the GitHub iOS Appstack SDK documentation. Please use the latest available version of the SDK.

Requirements

  1. iOS 13.0+
  2. Xcode 14.0+
  3. Swift 5.0+

Initial setup

1

Installation

You can install the SDK via Swift Package Manager (SPM) by adding the following dependency to your Package.swift file:
dependencies: [
    // Set `from:` to the latest stable semver from the repo’s releases (do not leave a stale pin).
    .package(url: "https://github.com/appstack-tech/ios-appstack-sdk.git", from: "X.Y.Z")
]
Or directly from Xcode:
  1. Go to File > Add Packages.
  2. Enter the repository URL: https://github.com/appstack-tech/ios-appstack-sdk.git.
  3. Select the desired version and click Add Package.
2

Initialization

Follow these steps to get the API key:
  1. In Appstack, from the side menu, select SDK and ensure you are selecting the correct application.
  2. Select the Production environment.
  3. Copy the API key.
AppDelegate
import UIKit
import AppTrackingTransparency
import AppstackSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Configure Appstack SDK
        AppstackAttributionSdk.shared.configure(
            apiKey: "your_api_key",
            isDebug: false,
            endpointBaseUrl: nil,
            logLevel: .info
        )
        
        // Request tracking permission and enable Apple Ads Attribution
        if #available(iOS 14.3, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                AppstackASAAttribution.shared.enableAppleAdsAttribution()
            }
        }
        
        return true
    }
}
SceneDelegate
import AppstackSDK

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
	func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    	AppstackAttributionSdk.shared.configure(
        	apiKey: "your_api_key",
        	isDebug: false,
        	endpointBaseUrl: nil,
        	logLevel: .info
    	)
	}
}
SwiftUI
import SwiftUI
import AppstackSDK

@main
struct MyApp: App {
	init() {
    	AppstackAttributionSdk.shared.configure(
        	apiKey: "your_api_key",
        	isDebug: false,
        	endpointBaseUrl: nil,
        	logLevel: .info
    	)
	}

	var body: some Scene {
    	WindowGroup {
        	ContentView()
    	}
	}
}
3

Configuration parameters

The AppstackAttributionSdk.shared.configure() method supports the following parameters:
  1. apiKey (String, required): Your Appstack API key.
  2. isDebug (Bool, default: false): Leave as ‘false’ for production. See Development setup if you need to test against the development environment.
  3. logLevel (LogLevel, default: .info): Logging level for debugging.
Configuration examples
// Production configuration
AppstackAttributionSdk.shared.configure(
    apiKey: "your_api_key",
    isDebug: false,  // Uses production URL
    endpointBaseUrl: nil,
    logLevel: .info
)
4

Sending events

Important notes
  1. Always initialize the SDK before sending events
  2. Event names must match those defined in the Appstack platform
  3. Parameters are passed as a dictionary [String: Any] and can include any key-value pairs (e.g., revenue, currency, quantity)
  4. Revenue parameters support automatic type conversion (Double, Int, Float, String)
  5. Revenue ranges are configured in the Appstack platform and automatically synchronized
Predefined event valuesThe SDK provides better type safety with predefined event types:
// Standard events using EventType enum
AppstackAttributionSdk.shared.sendEvent(event: .LOGIN)
AppstackAttributionSdk.shared.sendEvent( 
	event: .PURCHASE,  
	parameters: ["revenue": 29.99, "currency": "USD"] 
)
AppstackAttributionSdk.shared.sendEvent( 
	event: .SUBSCRIBE, 
	parameters: ["revenue": 9.99, "currency": "USD"] 
)

// Custom events
AppstackAttributionSdk.shared.sendEvent(
	event: .CUSTOM, 
	name: "user_attributes", 
	parameters: [ 
		"email": "test@example.com", 
		"name": "first_name last_name", 
		"phone_number": "+33060000000", 
		"date_of_birth": "2026-02-01" 
	]
)
Available EventType valuesIt is recommended to use standard events for a smoother experience.
The INSTALL event is tracked automatically on SDK initialization. Do not send it manually.
public enum EventType: String {
// Authentication & account
case LOGIN
case SIGN_UP
case REGISTER

// Monetization
case PURCHASE
case ADD_TO_WISHLIST
case INITIATE_CHECKOUT
case START_TRIAL
case SUBSCRIBE

// Games / progression
case LEVEL_START
case LEVEL_COMPLETE

// Engagement
case TUTORIAL_COMPLETE
case SEARCH
case SHARE

// Catch-all
case CUSTOM  // For custom events
}
Enhanced app campaigns
When running enhanced app campaigns (EACs), it is highly recommended to send multiple parameters with the in-app event to improve matching quality.
For any event that represents revenue, we recommend sending:
  1. revenue or price (number).
  2. currency (string, e.g. EUR, USD).
AppstackAttributionSdk.shared.sendEvent(
event: .PURCHASE,
parameters: ["revenue": 4.99, "currency": "EUR"]
)
To improve matching quality on Meta and TikTok, send events including the following parameters if you can fulfill them:
  1. email.
  2. name (first + last name in the same field).
  3. phone_number.
  4. date_of_birth (recommended format: YYYY-MM-DD).

Advanced configuration

SDK behavior

The SDK automatically:
  • Fetches configuration from Appstack servers.
  • Manages conversion value updates based on event tracking.
  • Handles revenue range matching for conversion optimization.
  • Processes events in time-based windows (0-2 days, 3-7 days, 8-35 days).
  • Queues events when the configuration is not ready.

Event processing

  • Events are processed asynchronously to avoid blocking the main thread.
  • The SDK queues events if the configuration is not yet loaded.
  • Revenue parameters are automatically validated and converted to numeric values.
  • Events are matched against configured revenue ranges in real-time.

Development setup

If you want to test the SDK against the Appstack development environment before shipping, follow these extra steps:
  1. In Appstack, from the side menu, select SDK, switch to the Development environment, and copy the Development API key. This key is separate from your production key.
  2. In your configure(...) call, use the development key and set isDebug: true:
AppstackAttributionSdk.shared.configure(
    apiKey: "your_development_api_key",
    isDebug: true,
    logLevel: .debug
)
The isDebug flag must match the key you’re using: development key with isDebug: true, production key with isDebug: false. The flag tells the SDK which environment URL to route to.

Superwall

To start using the Superwall integration, click here to see the correct SDK documentation.

Apple Ads

To start using the Apple Ads integration, click here to see the correct SDK documentation.

Support

For questions or issues:
  1. Check the GitHub Repository.
  2. Contact our support team at support@appstack.tech.
  3. Open an issue in the repository.

Use Cursor, Claude Code, or another AI to validate your existing Appstack Swift SDK integration.

CursorOpen in Cursor