Java
Copied to your clipboardMobileCore.setLogLevel(LoggingMode.DEBUG);// MobileCore.setLogLevel(LoggingMode.VERBOSE);// MobileCore.setLogLevel(LoggingMode.WARNING);// MobileCore.setLogLevel(LoggingMode.ERROR);
Swift
Copied to your clipboardACPCore.setLogLevel(ACPMobileLogLevel.debug)// ACPCore.setLogLevel(ACPMobileLogLevel.verbose)// ACPCore.setLogLevel(ACPMobileLogLevel.warning)// ACPCore.setLogLevel(ACPMobileLogLevel.error)
Objective-C
Copied to your clipboard[ACPCore setLogLevel:ACPMobileLogLevelDebug];// [ACPCore setLogLevel:ACPMobileLogLevelVerbose];// [ACPCore setLogLevel:ACPMobileLogLevelWarning];// [ACPCore setLogLevel:ACPMobileLogLevelError];
Javascript
Copied to your clipboardACPCore.setLogLevel(ACPMobileLogLevel.DEBUG);//ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);//ACPCore.setLogLevel(ACPMobileLogLevel.WARNING);//ACPCore.setLogLevel(ACPMobileLogLevel.ERROR);
Dart
Copied to your clipboardFlutterACPCore.setLogLevel(ACPLoggingLevel.DEBUG);//FlutterACPCore.setLogLevel(ACPLoggingLevel.VERBOSE);//FlutterACPCore.setLogLevel(ACPLoggingLevel.WARNING);//FlutterACPCore.setLogLevel(ACPLoggingLevel.ERROR);
Cordova
Copied to your clipboardACPCore.setLogLevel(ACPCore.ACPMobileLogLevelError, successCallback, errorCallback);ACPCore.setLogLevel(ACPCore.ACPMobileLogLevelWarning, successCallback, errorCallback);ACPCore.setLogLevel(ACPCore.ACPMobileLogLevelDebug, successCallback, errorCallback);ACPCore.setLogLevel(ACPCore.ACPMobileLogLevelVerbose, successCallback, errorCallback);
C#
Copied to your clipboardACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.ERROR);ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.WARNING);ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.DEBUG);ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);
Java
With the onResume
function, start Lifecycle data collection:
Copied to your clipboard@Overridepublic 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@Overridepublic void onPause() {MobileCore.lifecyclePause();}
Swift
Start Lifecycle data collection by calling lifecycleStart:
from within the callback of the ACPCore::start:
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 clipboardfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {// register the lifecycle extensionACPLifecycle.registerExtension();let appState = application.applicationState;ACPCore.start {// only start lifecycle if the application is not in the backgroundif appState != .background {ACPCore.lifecycleStart(nil)}}}
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 clipboardfunc applicationWillEnterForeground(_ application: UIApplication) {ACPCore.lifecycleStart(nil)}
When the app enters the background, pause Lifecycle data collection from your app's applicationDidEnterBackground:
delegate method:
Copied to your clipboardfunc applicationDidEnterBackground(_ application: UIApplication) {ACPCore.lifecyclePause()}
Objective-C
Start Lifecycle data collection by calling lifecycleStart:
from within the callback of the ACPCore::start:
method in your app's application:didFinishLaunchingWithOptions:
delegate method.
If your iOS application supports background capabilities, you application:didFinishLaunchingWithOptions:
method may 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[ACPLifecycle registerExtension];const UIApplicationState appState = application.applicationState;[ACPCore start:^{// only start lifecycle if the application is not in the backgroundif (appState != UIApplicationStateBackground) {[ACPCore lifecycleStart:nil];}}];}
When launched, if your app is resuming from a backgrounded state, iOS may 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 {[ACPCore lifecycleStart:nil];}
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 {[ACPCore lifecyclePause];}
JavaScript
You should implement Lifecycle metrics in native code. However, Lifecycle's APIs are available in Javascript if it fits your use case.
Starting a Lifecycle event
Copied to your clipboardACPCore.lifecycleStart({"lifecycleStart": "myData"});
Pausing a Lifecycle event
Copied to your clipboardACPCore.lifecyclePause();
Flutter
You need to implement Lifecycle in native Android and iOS code. For more information on implementing, please read the Lifecycle documentation.
Cordova
You need to implement Lifecycle in native Android and iOS code. For more information on implementing, please read the Lifecycle documentation.
Getting Lifecycle version
Copied to your clipboardACPLifecycle.extensionVersion(function(version) {console.log(version);}, function(error) {console.log(error);});
C#
Starting and pausing a lifecycle event
Copied to your clipboardprivate void OnApplicationPause(bool pauseStatus){if (pauseStatus){ACPCore.LifecyclePause();}else{var cdata = new Dictionary<string, string>();cdata.Add("launch.data", "added");ACPCore.LifecycleStart(cdata);}}
C#
iOS
Starting and pausing a lifecycle event
Copied to your clipboardpublic override void WillEnterForeground(UIApplication uiApplication){base.WillEnterForeground(uiApplication);ACPCore.LifecycleStart(null);}public override void DidEnterBackground(UIApplication uiApplication){base.DidEnterBackground(uiApplication);ACPCore.LifecycleStart(null);}
Android
Starting and pausing a lifecycle event
Copied to your clipboardprotected override void OnResume(){base.OnResume();ACPCore.LifecycleStart(null);}protected override void OnPause(){base.OnPause();ACPCore.LifecyclePause();}