Lifecycle API reference

extensionVersion

The extensionVersion() API returns the version of the Lifecycle extension that is registered with the Mobile Core extension.

To get the version of the Lifecycle extension, use the following code sample:

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static String extensionVersion()

Example

final String lifecycleExtensionVersion = Lifecycle.extensionVersion();

iOS Swift

data-slots=heading, code
data-repeat=2

Syntax

static var extensionVersion: String

Example

let version = Lifecycle.extensionVersion

iOS Objective-C

data-slots=heading, code
data-repeat=2

Syntax

@objc static var extensionVersion: String

Example

NSString *version = [AEPMobileLifecycle extensionVersion];

lifecycleStart

Starts the collection of lifecycle data.

For Analytics use case: Use this API to start a new lifecycle session or resume a previously paused lifecycle session. If a previously paused session timed out, then a new session is created. If a current session is running, then calling this method does nothing.

For Platform use case: Use this API to dispatch a Lifecycle Application Foreground event when the application is launched.

Android Java

This method should be called from the Activity onResume method.

data-slots=heading, code
data-repeat=2

Syntax

public static void lifecycleStart(@Nullable final Map<String, String> additionalContextData)

Example

MobileCore.lifecycleStart(null);

If you need to collect additional lifecycle data:

contextData.put("myapp.category", "Game");
MobileCore.lifecycleStart(additionalContextData);

iOS Swift

data-slots=heading, code
data-repeat=2

Syntax

 static func lifecycleStart(additionalContextData: [String: Any]?)

Example

 MobileCore.lifecycleStart(additionalContextData: nil)

If you need to collect additional lifecycle data:

 MobileCore.lifecycleStart(additionalContextData: ["contextDataKey": "contextDataVal"])

iOS Objective-C

data-slots=heading, code
data-repeat=2

Syntax

 @objc(lifecycleStart:)
 static func lifecycleStart(additionalContextData: [String: Any]?)

Example

 [AEPMobileCore lifecycleStart:nil];

If you need to collect additional lifecycle data:

 [AEPMobileCore lifecycleStart:@{@"contextDataKey": @"contextDataVal"}];

lifecyclePause

Pauses the collection of lifecycle data.

For Analytics use case: Use this API to pause the collection of lifecycle data.

For Platform use case: Use this API to dispatch a Lifecycle Application Background event when the application closes.

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static void lifecyclePause()

Example

MobileCore.lifecyclePause();

iOS Swift

data-slots=heading, code
data-repeat=2

Syntax

 static func lifecyclePause()

Example

 MobileCore.lifecyclePause()

iOS Objective-C

data-slots=heading, code
data-repeat=2

Syntax

 @objc(lifecyclePause)
 static func lifecyclePause()

Example

 [AEPMobileCore lifecyclePause];

registerExtension

data-variant=warning
data-slots=text1, text2
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use MobileCore.registerExtensions() API instead.

Registers the Lifecycle extension with the Mobile Core.

Android Java

data-slots=heading, code
data-repeat=2

Syntax

public static void registerExtension()

Example

Lifecycle.registerExtension();
export const _frontmatter = {}