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:
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet version = Lifecycle.extensionVersion
Objective-C
Syntax
Copied to your clipboard@objc static var extensionVersion: String
Example
Copied to your clipboardNSString *version = [AEPMobileLifecycle extensionVersion];
Java
Syntax
Copied to your clipboardpublic static String extensionVersion()
Example
Copied to your clipboardfinal String lifecycleExtensionVersion = Lifecycle.extensionVersion();
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet version = Lifecycle.extensionVersion
Objective-C
Syntax
Copied to your clipboard@objc static var extensionVersion: String
Example
Copied to your clipboardNSString *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.
Java
This method should be called from the Activity onResume method.
Syntax
Copied to your clipboardpublic static void lifecycleStart(@Nullable final Map<String, String> additionalContextData)
Example
Copied to your clipboardMobileCore.lifecycleStart(null);
If you need to collect additional lifecycle data:
Copied to your clipboardcontextData.put("myapp.category", "Game");MobileCore.lifecycleStart(additionalContextData);
Swift
Syntax
Copied to your clipboardstatic func lifecycleStart(additionalContextData: [String: Any]?)
Example
Copied to your clipboardMobileCore.lifecycleStart(additionalContextData: nil)
If you need to collect additional lifecycle data:
Copied to your clipboardMobileCore.lifecycleStart(additionalContextData: ["contextDataKey": "contextDataVal"])
Objective-C
Syntax
Copied to your clipboard@objc(lifecycleStart:)static func lifecycleStart(additionalContextData: [String: Any]?)
Example
Copied to your clipboard[AEPMobileCore lifecycleStart:nil];
If you need to collect additional lifecycle data:
Copied to your clipboard[AEPMobileCore lifecycleStart:@{@"contextDataKey": @"contextDataVal"}];
Java
This method should be called from the Activity onResume method.
Syntax
Copied to your clipboardpublic static void lifecycleStart(@Nullable final Map<String, String> additionalContextData)
Example
Copied to your clipboardMobileCore.lifecycleStart(null);
If you need to collect additional lifecycle data:
Copied to your clipboardcontextData.put("myapp.category", "Game");MobileCore.lifecycleStart(additionalContextData);
Swift
Syntax
Copied to your clipboardstatic func lifecycleStart(additionalContextData: [String: Any]?)
Example
Copied to your clipboardMobileCore.lifecycleStart(additionalContextData: nil)
If you need to collect additional lifecycle data:
Copied to your clipboardMobileCore.lifecycleStart(additionalContextData: ["contextDataKey": "contextDataVal"])
Objective-C
Syntax
Copied to your clipboard@objc(lifecycleStart:)static func lifecycleStart(additionalContextData: [String: Any]?)
Example
Copied to your clipboard[AEPMobileCore lifecycleStart:nil];
If you need to collect additional lifecycle data:
Copied to your clipboard[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.
registerExtension
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.