iOS SDK (Swift)
Add install and purchase attribution to your iOS app with a native Swift package.
Prerequisites
- iOS 15.0 or later
- Xcode 15 or later
- Swift 5.9 or later
- An Instally account with an App ID and API Key (available at app.instally.io)
Step 1: Add the Swift Package
In Xcode, go to File → Add Package Dependencies and enter the following repository URL:
Swift Package URL
https://github.com/instally/instally-ios-sdkSet the version rule to 1.0.0 -- Next Major Version and click Add Package. Xcode will resolve the dependency and add it to your project.
Using Package.swift?
If you manage dependencies through a
Package.swift file, add the dependency like this:Package.swift
.package(url: "https://github.com/instally/instally-ios-sdk", from: "1.0.0")Step 2: Configure and track install
Add the Instally import and call configure() and trackInstall() at your app's entry point. Replace the placeholder values with the App ID and API Key from your Instally dashboard.
SwiftUI App
MyApp.swift
import SwiftUI
import Instally
@main
struct MyApp: App {
init() {
Instally.configure(appId: "YOUR_APP_ID", apiKey: "YOUR_API_KEY")
Instally.trackInstall()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}UIKit AppDelegate
AppDelegate.swift
import UIKit
import Instally
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Instally.configure(appId: "YOUR_APP_ID", apiKey: "YOUR_API_KEY")
Instally.trackInstall()
return true
}
}Step 3: Track purchases (optional)
To attribute revenue to referrers, call trackPurchase() after every successful in-app purchase.
StoreKit 2
StoreManager.swift
import StoreKit
import Instally
func purchase(_ product: Product) async throws {
let result = try await product.purchase()
switch result {
case .success(let verification):
let transaction = try verification.payloadValue
Instally.trackPurchase(
productId: product.id,
revenue: product.price,
currency: "USD",
transactionId: String(transaction.id)
)
await transaction.finish()
case .userCancelled, .pending:
break
@unknown default:
break
}
}Classic StoreKit (SKPaymentQueue)
PaymentObserver.swift
import StoreKit
import Instally
func paymentQueue(
_ queue: SKPaymentQueue,
updatedTransactions transactions: [SKPaymentTransaction]
) {
for transaction in transactions {
switch transaction.transactionState {
case .purchased:
let productId = transaction.payment.productIdentifier
let transactionId = transaction.transactionIdentifier ?? ""
Instally.trackPurchase(
productId: productId,
revenue: 9.99,
currency: "USD",
transactionId: transactionId
)
queue.finishTransaction(transaction)
default:
break
}
}
}Important notes
No IDFA or ATT required
The Instally SDK does not use the Advertising Identifier (IDFA) and does not require an App Tracking Transparency prompt. Attribution is handled through deterministic matching without device-level ad tracking.
trackInstall()is safe to call on every app launch. It only fires once per install.trackPurchase()should be called after every successful in-app purchase to ensure accurate revenue attribution.- The SDK is under 200 KB with zero external dependencies.
- Works alongside any other analytics or attribution provider.