App Misuse
Introducing a new service to send information about application usage to our servers.
Usage
Please contact IMS sales to use this feature.
Importing the library
To use AppMisuse APIs, add the module dependency and follow the platform-specific instructions below.
//Add IMSAppMisuse xcFramework to your project
import IMSAppMisuse
Configure AppMisuse (iOS Only)
Initialize the AppMisuse service by creating PermissionManager objects and passing them to the AppMisuseManager constructor.
import IMSAppMisuse
import IMSInterfaces
import IMSPermissions
import IMSBluetooth
let permissionManager = PermissionManager()
// Add Permission Providers
permissionManager.addPermissionProvider(CLLocationManager(), isRequired: true)
permissionManager.addPermissionProvider(CMMotionActivityManager(), isRequired: true)
// Add this, if app requires bluetooth permissions for trip detection
permissionManager.addPermissionProvider(BluetoothPermissionProvider(), isRequired: true)
let appMisuseService = AppMisuseManager(permissionManageable: permissionManager)
Note:
The AppMisuseManager component uses the identity set during the login process to make API calls. Please ensure that the identity is correctly configured during login prior to utilizing AppMisuseManager functionality. Refer Link
Upon AppMisuseManager initialization, the AppMisuse feature is automatically enabled or disabled based on the internal SDKConfig settings and the deployment environment's configuration.
To enable AppMisuse capture hourly data, the host app must be registered with BGTaskSchedulerPermittedIdentifiers. Refer Link
Configure AppMisuse (Android Only)
Enabling AppMisuse API
This API enables the AppMisuse Service and activates the internal scheduler that automatically sends AppMisuse events every hour.
Here's an example.
AppMisuseManager.enableAppMisuse(context)
Disabling AppMisuse API
This API disables the AppMisuse Service and stops the internal scheduler that sends hourly AppMisuse events.
Here's an example.
AppMisuseManager.disableAppMisuse(context)
Calling AppMisuse API
There are a number of API's available depending on the required service. Please use the appropriate one accordingly. These APIs support both iOS and Android platforms.
AppMisuse Login API
This API sends AppMisuse information on Login.
Here's an example.
appMisuseService.sendAppMisuseEvent(eventType: .login) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
Usage: Call this API each time a user logs into the app or when switching users. This API captures the AppMisuse state when a user logs in. This does not need to be called each time the Identity is set or each time the app starts up.
AppMisuse Logout API
This API sends AppMisuse information on Logout.
Here's an example.
appMisuseService.sendAppMisuseEvent(eventType: .logout) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
Usage: Call this API when explicitly logging out a user or when switching users. This API captures the AppMisuse state when a user logs out. This API is a best effort API. If there is no network connection at the time of calling this API, the data will fail to send to our servers and will not retry as the SDK will no longer have access to the Identity for the user.
AppMisuse User App Launch API
This API sends AppMisuse information on User Launch.
Here's an example.
appMisuseService.sendAppMisuseEvent(eventType: .userAppLaunch) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
Usage: Call this API each time your app is opened by the user. This information can be used in Engagement and App Misuse rules related to inactivity.
Last updated