Initialize the SDK

Prev Next

What initialization means

Initialization is the step where you pass at least one Track ID and a valid Track Domain to MappIntelligence.shared()?.initWithConfiguration(...). From this point on, the SDK is available to the rest of your app.

Where initialization should happen

Initialize the SDK once during app startup:

  • In a UIKit app: in your AppDelegate's application(_:didFinishLaunchingWithOptions:).

  • In a SwiftUI app: in the init() of your @main App struct, or in an UIApplicationDelegateAdaptor.

This follows common iOS startup practice for app-wide libraries: initialize them once at app launch, not lazily from individual screens.

Note: watchOS and tvOS are no longer supported (sunset with version 5.0.6, December 2023). The SDK targets iOS (and iPadOS) only.

Minimum required configuration

You must provide:

  • at least one Track ID

  • a valid Track Domain (HTTPS)

Example

UIKit (AppDelegate):

import UIKit
import MappIntelligence

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        MappIntelligence.shared()?.initWithConfiguration(
            [123451234512345],
            onTrackdomain: "https://your-trackdomain.com"
        )
        return true
    }
}

SwiftUI (App lifecycle):

import SwiftUI
import MappIntelligence

@main
struct MyApp: App {
    init() {
        MappIntelligence.shared()?.initWithConfiguration(
            [123451234512345],
            onTrackdomain: "https://your-trackdomain.com"
        )
    }
    var body: some Scene {
        WindowGroup { ContentView() }
    }
}
#import "AppDelegate.h"
#import <MappIntelligence/MappIntelligence.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[MappIntelligence shared]
        initWithConfiguration:@[@123451234512345]
                onTrackdomain:@"https://your-trackdomain.com"];
    return YES;
}

@end

What to verify after initialization

  • the app starts without errors

  • your Track ID and Track Domain values are correct

  • the Track Domain uses https://

  • the initialization code runs exactly once during app startup

What not to overload into this step

Keep initialization minimal. Logging, request interval, batch support, user matching, crash tracking, and other optional behavior should be set in Configure Global Tracking.

Next step

Once the SDK starts successfully, continue with Configure Global Tracking.

If the SDK is not initialized correctly, later SDK calls can fail because the required configuration is missing.