Skip to content

getappsprint/appsprint-ios-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppSprint iOS SDK

Lightweight mobile attribution SDK for iOS. Tracks installs, events, and campaign attribution with offline support and Apple Ads integration.

Installation

Swift Package Manager (Recommended)

Add this package in Xcode:

  1. File > Add Package Dependencies
  2. Enter: https://github.com/getappsprint/appsprint-ios-sdk
  3. Select version rule: "Up to Next Major" from 1.1.3

Or add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/getappsprint/appsprint-ios-sdk", from: "1.1.3")
]

CocoaPods

pod 'AppSprintSDK', '~> 1.1.3'

Quick Start

import AppSprintSDK

// Configure on app launch
let config = AppSprintConfig(apiKey: "as_live_your_api_key")
await AppSprint.shared.configure(config)

// Track events
await AppSprint.shared.sendEvent(.purchase, name: "premium_upgrade", params: ["price": 9.99])

// Get attribution
if let attribution = AppSprint.shared.getAttribution() {
    print("Source: \(attribution.source)")
}

Configuration

let config = AppSprintConfig(
    apiKey: "as_live_...",                    // Required
    apiURL: URL(string: "https://api.appsprint.app")!,  // Default
    enableAppleAdsAttribution: true,          // Default: true
    isDebug: false,                           // Default: false
    logLevel: .warn,                          // Default: .warn
    customerUserId: nil,                      // Optional
    autoTrackSessions: true,                  // Default: true. Auto-fires .sessionStart on
                                              // configure() and foreground, debounced 30 min.
    autoRefreshAttribution: true              // Default: true. Refreshes attribution on
                                              // configure() and foreground so server-side
                                              // late resolution propagates.
)

API Reference

// Lifecycle
AppSprint.shared.configure(_ config: AppSprintConfig) async
AppSprint.shared.destroy()
AppSprint.shared.isInitialized -> Bool

// Events
AppSprint.shared.sendEvent(_ type: AppSprintEventType, name: String?, params: [String: Any]?) async
AppSprint.shared.sendTestEvent() async -> TestEventResult
AppSprint.shared.flush() async

// Attribution
AppSprint.shared.getAttribution() -> AttributionResult?
AppSprint.shared.getAttributionParams() -> [String: String]
AppSprint.shared.getAppSprintId() -> String?
AppSprint.shared.refreshAttribution() async -> AttributionResult?
AppSprint.shared.enableAppleAdsAttribution() -> Bool

// User
AppSprint.shared.setCustomerUserId(_ userId: String) async

// State
AppSprint.shared.isSdkDisabled() -> Bool
AppSprint.shared.clearData()

Event Types

sessionStart, login, signUp, register, purchase, subscribe, startTrial, addPaymentInfo, addToCart, addToWishlist, initiateCheckout, viewContent, viewItem, search, share, tutorialComplete, achieveLevel, levelStart, levelComplete, custom

Privacy

The XCFramework ships a PrivacyInfo.xcprivacy manifest. Match these entries in your App Store privacy details when you submit a build:

Manifest entry What it declares
NSPrivacyAccessedAPICategoryUserDefaults (reason CA92.1) The SDK reads/writes its own UserDefaults keys for install state, queued events, attribution cache, and retry flags.
NSPrivacyCollectedDataTypeDeviceID (Linked, Tracking) IDFA (when ATT is authorized), IDFV, and the SDK's own appsprintId are collected for analytics and third-party advertising attribution.
NSPrivacyCollectedDataTypeProductInteraction (Linked, Tracking) Event names, params, revenue, currency, and timestamps collected for analytics and third-party advertising attribution.
NSPrivacyCollectedDataTypeUserID (Linked, Tracking) customerUserId, when configured by the host app, is collected for install/event linking and attribution exports.
NSPrivacyCollectedDataTypeCoarseLocation (Linked, Tracking) Server-side request metadata can derive coarse geography for analytics and attribution reporting.
NSPrivacyCollectedDataTypeOtherDataTypes (Linked, Tracking) Custom event parameters are developer-defined and may include app-specific analytics fields.
NSPrivacyTracking: true The SDK is a tracking SDK in Apple's terminology.
NSPrivacyTrackingDomains api.appsprint.app - the SDK's ingest endpoint.

Required host-app Info.plist entries:

  • NSUserTrackingUsageDescription is required if you call AppSprintNative.requestTrackingAuthorization() or otherwise request IDFA access.
  • NSAdvertisingAttributionReportEndpoint is required if you use SKAdNetwork postbacks.

Do not put raw user PII into params for sendEvent or into customerUserId. Both are persisted to UserDefaults for retry durability; Apple documents UserDefaults as storage for nonsensitive settings.

Requirements

  • iOS 14.0+
  • Swift 5.9+
  • Xcode 15+

License

MIT License. See LICENSE for details.

About

AppSprint iOS SDK binary distribution via Swift Package Manager and CocoaPods

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors