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.

//Add IMSAppMisuse xcFramework to your project 
import IMSAppMisuse

Initializing the AppMisuse Library (iOS)

Initialize the AppMisuse API by creating PermissionManager objects, then pass them to AppMisuseManager.

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)

Important Notice:

  • AppMisuseManager has been simplified. The identity and serverType parameters are no longer required during initialization. Please update your implementation accordingly.

  • 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

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 app misuse scheduler to send the event type every hour by calling AppMisuseManager.enableAppMisuse()

    • Ensure to call the mentioned API within application(_:didFinishLaunchingWithOptions:) of app life cycle and register the scheduler key in the info.plist file for registering the scheduler.

    • For more information on setup, check here.

Here's an example.

// Enable the scheduler in application(_:didFinishLaunchingWithOptions:)
AppMisuseManager.enableAppMisuse()

Disabling App misuse API

This API disables the AppMisuse API Service.

Here's an example.

appMisuseService.disableAppMisuse()

Misuse 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)
    }
}

Misuse 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)
    }
}

Misuse 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)
    }
}

Last updated