Edit in GitHubLog an issue

Add the required dependencies to your project by including them in the app's Gradle file.

Copied to your clipboard
implementation(platform("com.adobe.marketing.mobile:sdk-bom:3.+"))
implementation("com.adobe.marketing.mobile:core")
implementation("com.adobe.marketing.mobile:lifecycle")

Add the required dependencies to your project by including them in the app's Gradle file.

Copied to your clipboard
implementation platform('com.adobe.marketing.mobile:sdk-bom:3.+')
implementation 'com.adobe.marketing.mobile:core'
implementation 'com.adobe.marketing.mobile:lifecycle'

Add the required dependencies to your project using CocoaPods. Add following pods in your Podfile:

Copied to your clipboard
use_frameworks!
target 'YourTargetApp' do
pod 'AEPCore', '~> 5.0'
pod 'AEPLifecycle', '~> 5.0'
end

Java

Add the following to each Android Activity class.

Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Lifecycle;
...
Copied to your clipboard
@Override
public void onResume() {
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}
Copied to your clipboard
@Override
public void onPause() {
MobileCore.lifecyclePause();
}

Kotlin

Add the following to each Android Activity class.

Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore
import com.adobe.marketing.mobile.Lifecycle
...
Copied to your clipboard
override fun onResume() {
MobileCore.setApplication(this.application)
MobileCore.lifecycleStart(null)
}
Copied to your clipboard
override fun onPause() {
MobileCore.lifecyclePause()
}
Copied to your clipboard
HashMap<String, Object> additionalContextData = new HashMap<String, Object>();
contextData.put("myapp.category", "Game");
MobileCore.lifecycleStart(additionalContextData);
Copied to your clipboard
MobileCore.lifecycleStart(mapOf("myapp.category" to "Game"))
Copied to your clipboard
MobileCore.lifecycleStart(additionalContextData: ["myapp.category": "Game"])
Copied to your clipboard
[AEPMobileCore lifecycleStart:@{@"myapp.category": @"Game"}];
Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Lifecycle;
public class MobileApp extends Application {
@Override
protected void onCreate() {
super.onCreate();
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityResumed(Activity activity) {
MobileCore.setApplication(activity.getApplication());
MobileCore.lifecycleStart(null);
}
@Override
public void onActivityPaused(Activity activity) {
MobileCore.lifecyclePause();
}
// the following methods aren't needed for our lifecycle purposes, but are
// required to be implemented by the ActivityLifecycleCallbacks object
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {}
@Override
public void onActivityStarted(Activity activity) {}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {}
@Override
public void onActivityDestroyed(Activity activity) {}
});
...
}
...
}
Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore
import com.adobe.marketing.mobile.Lifecycle
class MobileApp : Application() {
override fun onCreate() {
super.onCreate()
registerActivityLifecycleCallbacks(object: ActivityLifecycleCallbacks {
override fun onActivityResumed(activity: Activity) {
MobileCore.setApplication(activity.application)
MobileCore.lifecycleStart(null)
}
override fun onActivityPaused(activity: Activity) {
MobileCore.lifecyclePause()
}
// the following methods aren't needed for our lifecycle purposes, but are
// required to be implemented by the ActivityLifecycleCallbacks object
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
})
...
}
...
}
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)
}
}
}
Copied to your clipboard
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
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];
}
}];
}

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

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

In iOS 12 and earlier, use the UIApplicationDelegate as follows:

Copied to your clipboard
func applicationWillEnterForeground(_ application: UIApplication) {
MobileCore.lifecycleStart(additionalContextData: nil)
}
Copied to your clipboard
func applicationDidEnterBackground(_ application: UIApplication) {
MobileCore.lifecyclePause()
}

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

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

In iOS 12 and earlier, use the UIApplicationDelegate as follows:

Copied to your clipboard
- (void) applicationWillEnterForeground:(UIApplication *)application {
[AEPMobileCore lifecycleStart:nil];
}
Copied to your clipboard
- (void) applicationDidEnterBackground:(UIApplication *)application {
[AEPMobileCore lifecyclePause];
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.