Skip to main content

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+

Swift Package Manager

You can install the SDK via Swift Package Manager (SPM) by adding the following dependency to your Package.swift file:
dependencies: [
    .package(url: "https://github.com/appstack-tech/ios-appstack-sdk.git", from: "4.0.1")
]
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

Initial setup

1

Configuring the SKAdNetwork attribution endpoint (optional)

Option 1: Through Info.plist add the following entry to your Info.plist file:
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://ios-appstack.com/</string>
Option 2: Through Xcode
  1. Open your Info.plist file
  2. Add a new entry with the key: Advertising attribution report endpoint URL
  3. Set the value to: https://ios-appstack.com/
2

Initialization

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 v2.1.0+
        AppstackAttributionSdk.shared.configure(
            apiKey: "your_api_key",
            isDebug: false,  // Set to true for development
            endpointBaseUrl: nil,
            logLevel: .info
        )
        
        // Request tracking permission and enable Appple 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): If true, uses the development URL automatically
  3. endpointBaseUrl (String?, default: nil): Custom endpoint URL (optional)
  4. 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.
public enum EventType: String {
// Lifecycle
case INSTALL

// Authentication & account
case LOGIN
case SIGN_UP
case REGISTER

// Monetization
case PURCHASE
case ADD_TO_CART
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 VIEW_ITEM
case VIEW_CONTENT
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, 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)

Superwall

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

Apple Ads

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

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