Learn how to collect lifecycle data in a mobile app.
The Adobe Experience Platform Mobile SDK Lifecycle extension enables the collection lifecycle data from your mobile app. The Adobe Experience Platform Edge Network extension sends this lifecycle data to the Platform Edge Network where it is then forwarded to other applications and services according to your datastream configuration. Learn more about the Lifecycle extension in the product documentation.
Successfully built and run app with SDKs installed and configured.
Imported the Assurance SDK.
import AEPAssurance
Registered the Assurance extension as described in the previous lesson.
In this lesson, you will:
The Consumer Experience Event field group you added in the previous lesson already contains the lifecycle fields, so you can skip this step. If you don’t use Consumer Experience Event field group in your own app, you can add the lifecycle fields by doing the following:
Now you can update AppDelegate.swift
to register the lifecycle events:
When launched, if your app is resuming from a background state, iOS might call your applicationWillEnterForeground:
delegate method. Add lifecycleStart:
MobileCore.lifecycleStart(additionalContextData: nil)
When the app enters the background, pause Lifecycle data collection from your app’s applicationDidEnterBackground:
delegate method.
MobileCore.lifecyclePause()
For iOS 13 and later, please review the documentation for slightly different code.
LifecyclePause
.LifecycleResume
.The previous exercise dispatches the foreground and background events to Mobile SDK. To send these events to Platform Edge Network, follow the steps listed here. Once the events are sent to Platform Edge Network, they will be forwarded to other applications and services according to your datastream configuration.
Once you have added the rule to send the lifecyle events to Platform Edge Network, you should see Application Close (Background)
and Application Launch (Foreground)
events containing XDM data in Assurance.
Next: Track events
Thank you for investing your time in learning about Adobe Experience Platform Mobile SDK. If you have questions, want to share general feedback, or have suggestions on future content, please share them on this Experience League Community discussion post