Edit in GitHubLog an issue

Java

Copied to your clipboard
MobileCore.setLogLevel(LoggingMode.DEBUG);
// MobileCore.setLogLevel(LoggingMode.VERBOSE);
// MobileCore.setLogLevel(LoggingMode.WARNING);
// MobileCore.setLogLevel(LoggingMode.ERROR);

Swift

Copied to your clipboard
MobileCore.setLogLevel(.debug)
// MobileCore.setLogLevel(.trace)
// MobileCore.setLogLevel(.warning)
// MobileCore.setLogLevel(.error)

Objective-C

Copied to your clipboard
[AEPMobileCore setLogLevel:AEPLogLevelDebug];
// [AEPMobileCore setLogLevel:AEPLogLevelTrace];
// [AEPMobileCore setLogLevel:AEPLogLevelWarning];
// [AEPMobileCore setLogLevel:AEPLogLevelError];

Java

With the onResume function, start Lifecycle data collection:

Copied to your clipboard
@Override
public void onResume() {
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}

Setting the application is only necessary on activities that are entry points for your application. However, setting the application on each Activity has no negative impact and ensures that the SDK always has the necessary reference to your application. As a result, you should call setApplication on each of your activities.

You can use the onPause function to pause the lifecycle data collection:

To ensure accurate session and crash reporting, this call must be added to every Activity.

Copied to your clipboard
@Override
public void onPause() {
MobileCore.lifecyclePause();
}

Swift

  1. Register the Lifecycle extension with the SDK Core by adding the following to your app's application:didFinishLaunchingWithOptions: delegate method. This will register the extension with Core and begin Lifecycle event processing:
Copied to your clipboard
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MobileCore.registerExtensions([Lifecycle.self, ...], {
...
}
}
  1. Start Lifecycle data collection by calling lifecycleStart: from within the callback of the MobileCore.registerExtensions method in your app's application:didFinishLaunchingWithOptions: delegate method.

If your iOS application supports background capabilities, your application:didFinishLaunchingWithOptions: method might be called when iOS launches your app in the background. If you do not want background launches to count towards your lifecycle metrics, then lifecycleStart: should only be called when the application state is not equal to UIApplicationStateBackground.

Copied to your clipboard
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let appState = application.applicationState
MobileCore.registerExtensions([Lifecycle.self, ...], {
if appState != .background {
// only start lifecycle if the application is not in the background
MobileCore.lifecycleStart(additionalContextData: nil)
}
}
}
  1. When launched, if your app is resuming from a backgrounded state, iOS might call your applicationWillEnterForeground: delegate method. You also need to call lifecycleStart:, but this time you do not need all of the supporting code that you used in application:didFinishLaunchingWithOptions::
Copied to your clipboard
func applicationWillEnterForeground(_ application: UIApplication) {
MobileCore.lifecycleStart(additionalContextData: nil)
}

In iOS 13 and later, for a scene-based application, use the UISceneDelegate's sceneWillEnterForeground method as follows:

Copied to your clipboard
func sceneWillEnterForeground(_ scene: UIScene) {
MobileCore.lifecycleStart(additionalContextData: nil)
}

For more information on handling foregrounding applications with Scenes, refer to Apple's documentation here

  1. When the app enters the background, pause Lifecycle data collection from your app's applicationDidEnterBackground: delegate method:
Copied to your clipboard
func applicationDidEnterBackground(_ application: UIApplication) {
MobileCore.lifecyclePause()
}

In iOS 13 and later, for a scene-based application, use the UISceneDelegate's sceneDidEnterBackground method as follows:

Copied to your clipboard
func sceneDidEnterBackground(_ scene: UIScene) {
MobileCore.lifecyclePause()
}

For more information on handling backgrounding applications with Scenes, refer to Apple's documentation here

Objective-C

  1. Register the Lifecycle extension with the SDK Core by adding the following to your app's application:didFinishLaunchingWithOptions: delegate method. This will register the extension with Core and begin Lifecycle event processing:
Copied to your clipboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// register the lifecycle extension
[AEPMobileCore registerExtensions:@[AEPMobileLifecycle.class, ...] completion:^{
...
}];
return YES;
}
  1. Start Lifecycle data collection by calling lifecycleStart: from within the callback of the AEPMobileCore::registerExtensions: method in your app's application:didFinishLaunchingWithOptions: delegate method.

If your iOS application supports background capabilities, your application:didFinishLaunchingWithOptions: method might be called when iOS launches your app in the background. If you do not want background launches to count towards your lifecycle metrics, then lifecycleStart: should only be called when the application state is not equal to UIApplicationStateBackground.

Copied to your clipboard
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// register the lifecycle extension, and begin event processing with Core
const UIApplicationState appState = application.applicationState;
[AEPMobileCore registerExtensions:@[AEPMobileLifecycle.class, ...] completion:^{
// only start lifecycle if the application is not in the background
if (appState != UIApplicationStateBackground) {
[AEPMobileCore lifecycleStart:nil];
}
}];
}
  1. When launched, if your app is resuming from a backgrounded state, iOS might call your applicationWillEnterForeground: delegate method. You also need to call lifecycleStart:, but this time you do not need all of the supporting code that you used in application:didFinishLaunchingWithOptions::
Copied to your clipboard
- (void) applicationWillEnterForeground:(UIApplication *)application {
[AEPMobileCore lifecycleStart:nil];
}

In iOS 13 and later, for a scene-based application, use the UISceneDelegate's sceneWillEnterForeground method as follows:

Copied to your clipboard
- (void) sceneWillEnterForeground:(UIScene *)scene {
[AEPMobileCore lifecycleStart:nil];
}

For more information on handling foregrounding applications with Scenes, refer to Apple's documentation here

  1. When the app enters the background, pause Lifecycle data collection from your app's applicationDidEnterBackground: delegate method:
Copied to your clipboard
- (void) applicationDidEnterBackground:(UIApplication *)application {
[AEPMobileCore lifecyclePause];
}

In iOS 13 and later, for a scene-based application, use the UISceneDelegate's sceneDidEnterBackground method as follows:

Copied to your clipboard
- (void) sceneDidEnterBackground:(UIScene *)scene {
[AEPMobileCore lifecyclePause];
}

For more information on handling backgrounding applications with Scenes, refer to Apple's documentation here

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.