Sessions in Cocoa apps
A session is a single period of user interaction with your app. For example, when a user opens the app for the first time and when the app goes to the background, that is considered as a session.
Add the SDK
- Make sure that Apptics is integrated with your project. Refer to the integration guide.
Copiedsource 'https://github.com/CocoaPods/Specs.git'
target 'YourAppTargetName' do
pod 'Apptics-SDK'
end
- Run pod install to integrate the SDK into your app.
Initialize analytics in your app
Initialize Apptics in the application:didFinishLaunchingWithOptions: method of your AppDelegate.
Copied- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
[Apptics initializeWithVerbose:YES];
return YES;
}
Copiedfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Apptics.initialize(withVerbose: true)
return true
}
Automatic Session tracking
Session tracking is automatically handled by the AppticsAnalytics class when Apptics is initialized.
If you want to disable automatic session tracking, set the automaticSessionTrackingStatus to false before initializing Apptics.
CopiedAppticsConfig.defaultConfig.enableAutomaticSessionTracking = false
[Apptics initializeWithVerbose:YES];
CopiedAppticsConfig.default.enableAutomaticSessionTracking = false
Apptics.initialize(withVerbose: true)
Configurable parameters
You can customize the session duration and timeout by configuring the following parameters in AppticsConfig:
- Minimum session duration: This is the minimum duration (in seconds) for a session to be considered valid.
CopiedAppticsConfig.defaultConfig.minSessionDuration = <#APMinSessionDuration#>
CopiedAppticsConfig.default.minSessionDuration = <#APMinSessionDuration#>
- Maximum session timeout: This is the maximum timeout (in seconds) for a session.
CopiedAppticsConfig.defaultConfig.maxSessionTimeout = <#APMaxSessionTimeout#>
CopiedAppticsConfig.default.maxSessionTimeout = <#APMaxSessionTimeout#>