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 app misuse APIs, add the module dependency and initialize by sending login, logout, or userAppLaunch events.
Swift
Kotlin
//Add IMSAppMisuse xcFramework to your project
import IMSAppMisuse
dependencies {
...
implementation 'com.drivesync.android:imsappmisuse:1.19.0'
...
}

Initializing the Misuse Library(iOS)

Initialize the Misuse API by creating Identity and PermissionManager objects, then pass them to AppMisuseManager.
import IMSAppMisuse
import IMSInterfaces
import IMSPermissions
let identity = Identity(apiKey: apiKey,externalReferenceID: userId)
let permissionManager = PermissionManager()
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)
// Servertype can be used based on two environments (.uat or .prod)
let serverType = .uat
let appMisuseService = AppMisuseManager(identity: identity,permissionManageable: permissionManager,serverType: serverType))

Calling Misuse API

There are a number of API's available depending on the service you require; choose and call the appropriate one accordingly.

Enabling App misuse API

This API enables the Misuse API Service.

iOS SDK scheduler

  • Call the heartbeat scheduler to send the event type every hour by calling AppMisuseManager.enableAppMisuse()
    • Ensure to call the mentioned API during UserAppLaunch and register the Scheduler Key in the info.plist file for proper functionality
    • For more information on setup, check here.
Here's an example.
Swift
Kotlin
// Call the sendHeartbeat api with appropriate event types
appMisuseService.sendAppMisuseEvent(eventType: eventType) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
AppMisuseManager.enableAppMisuse(context,AppMisuseManager.AppMisuseServerType)

Disabling App misuse API

This API disables the Misuse API Service.
Here's an example.
Swift
Kotlin
appMisuseService.disableAppMisuse()
AppMisuseManager.disableAppMisuse(context)

Misuse Login API

This API sends Misuse information on Login.
Here's an example.
Swift
Kotlin
appMisuseService.sendAppMisuseEvent(eventType: .login) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
AppMisuseManager.sendLoginEvent(context)

Misuse Logout API

This API sends Misuse information on Logout.
Here's an example.
Swift
Kotlin
appMisuseService.sendAppMisuseEvent(eventType: .logout) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
AppMisuseManager.sendLogoutEvent(context)

Misuse User App Launch API

This API sends Misuse information on User Launch.
Here's an example.
Swift
Kotlin
appMisuseService.sendAppMisuseEvent(eventType: .userAppLaunch) { result in
switch result {
case .success:
// successful call
case .failure(let error):
// failed with \(error)
}
}
AppMisuseManager.sendAppLaunchEvent(context)