Skip to main content

Lifecycle Tracking (iOS)

OpenCDP for iOS provides automatic tracking for common application lifecycle events.

Configuration​

Enable lifecycle tracking in your OpenCDPConfig.

let config = OpenCDPConfig(
cdpApiKey: "YOUR_API_KEY",
debug: true,
autoTrackScreens: true,
trackApplicationLifecycleEvents: true,
autoTrackDeviceAttributes: true
)

Automatic Screen Tracking​

When autoTrackScreens is enabled, the SDK hooks into UIViewController lifecycle events to automatically record screen views.

Lifecycle Events​

The following events are tracked automatically when trackApplicationLifecycleEvents is enabled:

Event NameDescription
application_openedRecorded when UIApplication.didBecomeActiveNotification is received.
application_backgroundedRecorded when UIApplication.didEnterBackgroundNotification is received.

Device Attributes​

When autoTrackDeviceAttributes is enabled, the SDK automatically collects:

  • Device Model (e.g., "iPhone 15 Pro")
  • System Name & Version
  • App Version and Build Number
  • Locale Information
  • Timezone