Intempt Docs
Developer DocsSDK

iOS SDK

Track user interactions within your iOS app and manage configuration via the Intempt console.

iOS SDK

The Intempt iOS SDK tracks user interactions within your iOS app and lets you manage configuration through the Intempt console. The framework automatically collects rich event data on initialization with no additional code required.

Auto-Tracked Events

EventDescription
TouchUser taps on interactive UI controls
View ScreenScreen navigation and engagement
Leave ScreenUser exits from screens
ActionForm submissions and link clicks
App Install/UpgradeInstallations with version and build details
Start SessionBeginning of a new user session
End SessionRecorded after 5 minutes of inactivity

Requirements

  • iOS 13.0+
  • Xcode 11.0 or later

Installation

Swift Package Manager

  1. Open your .xcodeproj in Xcode
  2. Go to File → Add Packages
  3. Enter the repository URL: https://github.com/intempt/intempt-intemptios
  4. Select the master branch

Manual Framework

  1. Download the SDK repository as a ZIP
  2. Locate Intempt.xcframework
  3. Drag it into your Xcode project
  4. In Build Phases, add it under Embed Frameworks
  5. In General → Frameworks, set it to Embed & Sign

Setup

Before initializing, obtain the following from the Intempt console (Integrations → Sources):

  • Organization name
  • Project name
  • Source ID
  • API Key

Initialization

Swift — SceneDelegate

import Intempt

func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
           options connectionOptions: UIScene.ConnectionOptions) {
    guard let _ = (scene as? UIWindowScene) else { return }

    let intemptConfig = IntemptConfig(
        queueEnabled: true,
        withItemsInQueue: 7,
        withTimeBuffer: 15,
        withInitialDelay: 0.3,
        withInputTextCaptureDisabled: false
    )

    Intempt.initialize(<orgName>, projectName: <projectName>,
                       sourceId: <sourceId>, apiKey: <apiKey>,
                       intemptConfig: intemptConfig) { (status, result, error) in
        if status, let dictResult = result as? [String: Any] {
            print(dictResult)
        } else if let error = error {
            print(error.localizedDescription)
        }
    }
}

Swift — ViewController

override func viewDidLoad() {
    super.viewDidLoad()

    let intemptConfig = IntemptConfig(
        queueEnabled: true,
        withItemsInQueue: 7,
        withTimeBuffer: 15,
        withInitialDelay: 0.3,
        withInputTextCaptureDisabled: false
    )

    Intempt.initialize(<orgName>, projectName: <projectName>,
                       sourceId: <sourceId>, apiKey: <apiKey>,
                       intemptConfig: intemptConfig) { (status, result, error) in
        if status, let dictResult = result as? [String: Any] {
            print(dictResult)
        }
    }
}

Objective-C — AppDelegate

@import Intempt;

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    IntemptConfig *intemptConfig = [[IntemptConfig alloc]
        initWithQueueEnabled:YES
        withItemsInQueue:7
        withTimeBuffer:15
        withInitialDelay:0.3
        withInputTextCaptureDisabled:NO
    ];

    [Intempt initialize:<orgName>
            projectName:<projectName>
              sourceId:<sourceId>
                apiKey:<apiKey>
         intemptConfig:intemptConfig
         onCompletion:^(BOOL status, id result, NSError *error) {}];

    return YES;
}

IntemptConfig Parameters

ParameterTypeDefaultDescription
queueEnabledBOOLYESEnable event batching
itemsInQueueInt5Events per batch before sending
timeBufferTimeInterval5sInterval for periodic sends
isInputTextCaptureDisabledBOOLNODisable text input capture
initialDelayTimeInterval0.2sDelay before first send

Event Tracking

track()

Records a custom event with associated data.

let objData: [String: Any] = [
    "flightId": 1,
    "bookingDate": "2024-01-29",
    "bookingId": 2,
    "bookingStatus": "booked"
]

Intempt.track("flight-booking", data: objData) { (status, result, error) in
    if status, let dictResult = result as? [String: Any] {
        print(dictResult)
    }
}

record()

Tracks events with full user and account context.

let objData: [String: Any] = ["flightId": 1, "bookingDate": "2024-01-29"]
let accountAttributes: [String: Any] = ["mtuCount": "1000+"]
let userAttributes: [String: Any] = ["city": "New York", "country": "USA"]

Intempt.record("flight-booking",
    userId: "xyz@intempt.com",
    accountId: "intempt.com",
    data: objData,
    accountAttributes: accountAttributes,
    userAttributes: userAttributes) { (status, result, error) in }

User Identification

identify()

Associates events with a specific user.

// Basic
Intempt.identify("xyz@intempt.com") { (status, result, error) in }

// With attributes
let userAttributes: [String: Any] = ["city": "New York", "country": "USA"]

Intempt.identify("xyz@intempt.com",
    eventTitle: "CustomIdentify",
    userAttributes: userAttributes) { (status, result, error) in }

group()

Assigns a user to an account group.

// Basic
Intempt.group("intempt.com") { (status, result, error) in }

// With attributes
let accountAttributes: [String: Any] = ["name": "John", "country": "USA"]

Intempt.group("CustomGroupIdentify",
    accountId: "intempt.com",
    userAttributes: accountAttributes) { (status, result, error) in }

alias()

Links two user identities together.

Intempt.alias("xyz@intempt.com", anotherUserId: "abc@intempt.com")
    { (status, result, error) in }

Intempt.consents(
    IntemptConsentAction.Accept.rawValue,
    consentsExpirationTime: "Unlimited",
    email: "xyz@intempt.com",
    message: "Yes, email me offers.") { (status, result, error) in }
Intempt.consents(IntemptConsentAction.Reject.rawValue) { (status, result, error) in }
Intempt.consent(
    IntemptConsentAction.Accept.rawValue,
    consentsExpirationTime: "Unlimited",
    category: "News",
    email: "xyz@intempt.com",
    message: "Yes, email me offers.") { (status, result, error) in }

Product Tracking

productView()

Intempt.productView(productId: "123") { (status, result, error) in }

productAdd()

Intempt.productAdd(productId: "123", quantity: 1) { (status, result, error) in }

productOrdered()

var productsOrdered = [[String: Any]]()

for item in CartController.shared.items {
    productsOrdered.append(["productId": item.productId, "quantity": item.quantity])
}

Intempt.productOrdered(params: productsOrdered) { (status, result, error) in }

Recommendations

Intempt.recommendation(
    "9",
    fields: ["id", "price", "title"],
    quantity: 4,
    productId: productId) { (status, result, error) in }

Experiments & Personalization

// By name
Intempt.chooseExperiments(
    byNames: ["Special_Discount"],
    productId: "2369423736890") { (status, result, error) in }

// By group
Intempt.chooseExperiments(
    byGroups: ["Banners"],
    productId: "2369423736890") { (status, result, error) in }

// Personalization by name
Intempt.choosePersonalizations(
    byNames: ["home_page_pop-up"],
    productId: "2369423736890") { (status, result, error) in }

// Personalization by group
Intempt.choosePersonalizations(
    byGroups: ["banner"],
    productId: "2369423736890") { (status, result, error) in }

Utility Methods

MethodReturnsDescription
isUserOptIn()BooleanCheck opt-in status
optIn()VoidGrant tracking consent
optOut()VoidRevoke tracking consent
logout()VoidClear user session
getProfileId()StringGet current profile ID
getSesssionId()StringGet current session ID
enableLogging()VoidActivate debug logging
disableLogging()VoidDeactivate debug logging
disableTextInput(true)VoidToggle text capture
startTrackingSession()VoidStart a new session
endTrackingSession()VoidEnd the current session
validateTrackingSession()VoidConfirm session validity

Troubleshooting

IssueSolution
Framework architecture errorsSet Target → Build Settings → Validate Workspace to NO
App Store lipo errorsAdd a Run Script phase with a lipo-cleaning script
dyld library not loadedVerify Intempt.xcframework is set to Embed & Sign
Module not foundRemove framework, clean DerivedData, re-add Intempt.xcframework
No data in consoleEvents batch periodically — allow a few seconds after triggering
Slow transmissionReduce timeBuffer and itemsInQueue in IntemptConfig
Field type errorsMatch schema types exactly; new fields are fine, but existing field types cannot change

On this page