UIKit Apps
For UIKit-based applications with AppDelegate:1. Initialize in AppDelegate
import UIKit
import ZixflowDataPipelines
import ZixflowMessagingPushAPN
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Initialize Zixflow SDK
initializeZixflow()
return true
}
func initializeZixflow() {
// Configure the SDK
let config = SDKConfigBuilder(apiKey: "YOUR_API_KEY")
.autoTrackDeviceAttributes(true) // Auto-track device info
.trackApplicationLifecycleEvents(true) // Track app lifecycle
.logLevel(.debug) // Set log level
.build()
// Initialize core SDK
Zixflow.initialize(withConfig: config)
// Initialize push notifications (optional)
MessagingPushAPN.initialize(
withConfig: MessagingPushConfigBuilder()
.autoFetchDeviceToken(true)
.autoTrackPushEvents(true)
.showPushAppInForeground(true)
.build()
)
}
}
2. Replace Configuration Values
- YOUR_API_KEY: Your Zixflow API key (from Zixflow dashboard)
SwiftUI Apps
For SwiftUI applications with@main App struct:
1. Create AppDelegate Class
import UIKit
import ZixflowDataPipelines
import ZixflowMessagingPushAPN
class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
// Configure the SDK
let config = SDKConfigBuilder(apiKey: "YOUR_API_KEY")
.autoTrackDeviceAttributes(true)
.trackApplicationLifecycleEvents(true)
.logLevel(.debug)
.build()
Zixflow.initialize(withConfig: config)
// Initialize messaging features
MessagingPushAPN.initialize(
withConfig: MessagingPushConfigBuilder()
.autoFetchDeviceToken(true)
.autoTrackPushEvents(true)
.showPushAppInForeground(true)
.build()
)
return true
}
}
2. Connect AppDelegate to SwiftUI App
import SwiftUI
@main
struct YourApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}