The Lifecycle module automatically tracks app lifecycle events and associated data. The launch event is triggered when the library is loaded for the first time, sleep event on UIApplicationWillResignActive notification and wake event on UIApplicationDidBecomeActive.
Usage of this module is recommended if you are using Adobe Analytics. Otherwise, it is optional, but the additional events captured (launch/wake/sleep) may be useful to you for other vendor implementations.
The following platforms are supported:
If the UIKit dependency is added to the target app, no further configuration or implementation is necessary. For other platform builds (watchOS, macOS), the Lifecycle module functions may be triggered manually (see API Reference).
Install the Lifecycle module with Swift Package Manager, CocoaPods or Carthage.
Swift Package Manager (Recommended)
Supported in version 1.9.0+, the Swift Package Manager is the recommended and simplest way to install the Tealium Swift library:
In your Xcode project, select File > Swift Packages > Add Package Dependency
Enter the repository URL: https://github.com/tealium/tealium-swift
Configure the version rules. Typically, "Up to next major" is recommended. If the current Tealium Swift library version does not appears in the list, then reset your Swift package cache.
Select the Lifecycle module from the list of modules to install and add it each of your app targets in your Xcode project, under Frameworks > Libraries & Embedded Content
The following variables are transmitted with each tracking call while the module is enabled:
Was a crash detected during this launch/wake event. Populated only if true.
Local day of week that call was made, such as 1=Sunday, 2=Monday.
Days since first launch in integer increments.
Days since the last detected app version update in integer increments.
Days since last detected wake in integer increments.
GMT timestamp of the first detected launch/wake in ISO8601 format from Zulu time.
GMT Timestamp formatted as MM/DD/YYYY.
Local hour of day that call was made (24 hour format).
Only present if call is the first launch/wake call.
Only present if call is first launch/wake after a detected updated.
Only present if call is first launch/wake of the month.
Only present if call is first launch/wake of the day.
Total number of launches this version of your app (since the last update).
Whole seconds app was awake since last launch only. Aggregates total from all wakes prior. Sent only with lifecycle_type:launch calls.
Whole seconds app was awake since most recent wake/launch.
Total number of times your app has gone to sleep (resets if updated).
Total number of crashes counted since install (only reset if app deleted).
Total number of launches since install (only reset if app deleted)
Total number of seconds your app has been in a woken/active state since app install (only reset if app deleted).
Total number of times your app has gone into the background since app install (only reset if app deleted).
Total number of launches + wakes since install (only reset if app deleted).
GMT timestamp of first wake/launch after a version update has been detected .
Type of lifecycle call.
["launch", "wake", "sleep" ]
Total number of launches + wakes in this version of your app (resets if updated).
The Lifecycle module performs basic crash detection, but does not collect any details about the cause of the crash. It records a crash whenever a lifecycle launch event is seen, without a preceding sleep event.
Normally, when an app is closed by the user, a notification from the OS triggers a lifecycle sleep event, but if the app crashes, there is no time for this to happen, and thus, no sleep event takes place. On the subsequent launch after the crash, the lifecycle_diddetectcrash variable is set to true, and the lifecycle_totalcrashcount variable is incremented by 1.
If you require more advanced crash detection, our Crash Reporter module provides full details of each crash, and the reasons for the crash. This is currently supported on iOS only.
You only need to use the following API methods if you are targeting a platform that doesn’t support UIKit.
Updates lifecycle records with a launch event and trigger a lifecycle event dispatch.