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:
{% tabs %} {% tab title="Android" %}
String lifecycleExtensionVersion = Lifecycle.extensionVersion();
{% endtab %}
{% tab title="iOS (AEP 3.x)" %} Swift
let version = Lifecycle.extensionVersion
Objective C
NSString *version = [AEPMobileLifecycle extensionVersion];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %} Objective C
NSString *lifecycleExtensionVersion = [ACPLifecycle extensionVersion];
Swift
let lifecycleExtensionVersion = ACPLifecycle.extensionVersion()
{% endtab %}
{% tab title="React Native" %}
ACPLifecycle.extensionVersion().then(lifecycleExtensionVersion => console.log("AdobeExperienceSDK: ACPLifecycle version: " + lifecycleExtensionVersion));
{% endtab %}
{% tab title="Flutter" %}
String lifeycycleExtensionVersion = await FlutterACPLifecycle.extensionVersion;
{% endtab %}
{% tab title="Cordova" %}
ACPLifecycle.extensionVersion(function(version) {
console.log("ACPLifecycle version: " + version);
}, function(error) {
console.log(error);
});
{% endtab %}
{% tab title="Unity" %}
string lifecycleVersion = ACPLifecycle.ExtensionVersion();
{% endtab %}
{% tab title="Xamarin" %}
string lifecycleVersion = ACPLifecycle.ExtensionVersion();
{% endtab %} {% endtabs %}
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.
{% tabs %} {% tab title="Android" %}
Syntax
public static void lifecycleStart(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);
{% hint style="warning" %} This method should be called from the Activity onResume method. {% endhint %} {% endtab %}
{% tab title="iOS (AEP 3.x)" %}
MobileCore.lifecycleStart(additionalContextData: ["contextDataKey": "contextDataVal"])
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"}];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Syntax
+ (void) lifecycleStart: (nullable NSDictionary<NSString*, NSString*>*) additionalContextData;
Example
[ACPCore lifecycleStart:nil];
If you need to collect additional lifecycle data:
[ACPCore lifecycleStart:@{@"state": @"appResume"}];
ACPCore.lifecycleStart(["state": "appResume"])
{% endtab %}
{% tab title="React Native" %}
When using React Native, starting to collect lifecycle data should be done in native code which is shown under the Android and iOS (ACP 2.x) tabs.
{% endtab %}
{% tab title="Cordova" %}
When using Cordova, the lifecycleStart
method call must be made in native code which is shown under the Android and iOS tabs.
{% endtab %}
{% tab title="Unity" %}
When using Unity, the LifecycleStart
method call must be made from the OnApplicationPause
method.
private void OnApplicationPause(bool pauseStatus)
{
if (!pauseStatus)
{
ACPCore.LifecyclePause();
}
else
{
var cdata = new Dictionary<string, string>();
cdata.Add("launch.data", "added");
ACPCore.LifecycleStart(cdata);
}
}
{% endtab %}
{% tab title="Xamarin" %}
iOS
When using iOS, the LifecycleStart
method call must be made from the OnActivated
method.
public override void OnActivated(UIApplication uiApplication)
{
base.OnActivated(uiApplication);
ACPCore.LifecycleStart(null);
}
Android
When using Android, the LifecycleStart
method call must be made from the OnResume
method.
protected override void OnResume()
{
base.OnResume();
ACPCore.LifecycleStart(null);
}
{% endtab %} {% endtabs %}
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.
{% tabs %} {% tab title="Android" %}
Syntax
public static void lifecyclePause()
Example
MobileCore.lifecyclePause();
{% endtab %}
{% tab title="iOS (AEP 3.x)" %}
MobileCore.lifecyclePause()
Syntax
@objc(lifecyclePause)
static func lifecyclePause()
Example
[AEPMobileCore lifecyclePause];
{% endtab %}
{% tab title="iOS (ACP 2.x)" %}
Syntax
+ (void) lifecyclePause;
Example
[ACPCore lifecyclePause];
ACPCore.lifecyclePause()
{% endtab %}
{% tab title="React Native" %}
When using React Native, pausing the collection of lifecycle data should be done in native code which is shown under the Android and iOS (ACP 2.x) tabs.
{% endtab %}
{% tab title="Cordova" %}
When using Cordova, the lifecyclePause
method call must be made in native code which is shown under the Android and iOS tabs.
{% endtab %}
{% tab title="Unity" %}
When using Unity, the LifecyclePause
method call must be made from the OnApplicationPause
method.
private void OnApplicationPause(bool pauseStatus)
{
if (!pauseStatus)
{
ACPCore.LifecyclePause();
}
else
{
var cdata = new Dictionary<string, string>();
cdata.Add("launch.data", "added");
ACPCore.LifecycleStart(cdata);
}
}
{% endtab %}
{% tab title="Xamarin" %}
iOS
When using iOS, the LifecyclePause
method call must be made from the OnResignActivation
method.
public override void OnResignActivation(UIApplication uiApplication)
{
base.OnResignActivation(uiApplication);
ACPCore.LifecyclePause();
}
Android
When using Android, the LifecyclePause
method call must be made from the OnPause
method.
protected override void OnPause()
{
base.OnPause();
ACPCore.LifecyclePause();
}
{% endtab %} {% endtabs %}