acl_sdk 0.2.1 copy "acl_sdk: ^0.2.1" to clipboard
acl_sdk: ^0.2.1 copied to clipboard

A Flutter plugin which provide ACL functioning by Unified Intelligence. Which help you collect device's data and calculate device score.

Flutter ACL Plugin #

A Flutter plugin which provide ACL functioning by Unified Intelligence

Feature #

  • Collect device data: battery, device resource, network, app usage
  • Collect location
  • Collect notification
  • Store and sync data to server
  • Calculate score

IMPORTANT:

This plugin support both Android and iOS. Following features will not available on iOS version:

  • PermissionHelper.isNotificationListenerRunning
  • PermissionHelper.goToNotificationListenerSetting
  • PermissionHelper.isPackageUsageStatsEnable
  • PermissionHelper.goToAppUsageSetting

Please wrap those functions call in platform condition check!

How to install #

  • Step 1: Install package
flutter pub add acl_sdk
  • Step 2: This plugin use firebase_messaging to handle server-side message and perform action. You need to install firebase on your project with at least 2 packages firebase_core: ^3.4.1, firebase_messaging: ^15.1.1

On Android #

  • Step 3: Find your android build.gradle file at android\build.gradle and add following code to allow gradle build with aar library
allprojects {
  repositories {
    ...
    // Add following lines
    maven {
        // [required] aar plugin
        url "${project(':acl_sdk').projectDir}/build"
    }
  }
}

// ------- After added, your build.gradle will look like this -------

allprojects {
    repositories {
        google()
        mavenCentral()
        // Add following lines
        maven {
            // [required] aar plugin
            url "${project(':acl_sdk').projectDir}/build"
        }
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}


  • Step 4: Since this plugin require minSdkVersion = 24. You might need to update your project minSdkVersion to make it compatible. To do this, please find another build.gradle file at android\app\build.gradle then edit minSdk to 24.
    • Note: Depend on your project's structure, you can set it by using local.properties file or use directly number 24.
defaultConfig {
    ...
    minSdk = 24 // Edit this line
    ...
}

On iOS #

  • Step 3: Add Background mode which enable Background fetch, Location updates, Remote notifications (See sample info.plist below)
  <key>UIBackgroundModes</key>
	<array>
		<string>fetch</string>
		<string>remote-notification</string>
		<string>location</string>
	</array>
  • Step 4: Add Location always privacy if your app doesn't have this permission.

Usage #

  • To initialize the plugin and register device
import 'package:acl_sdk/acl_sdk.dart';

...

final _aclSdkPlugin = AclSdk();

...

await _aclSdkPlugin.initialize(AppConfigCreateInput(
  partnerId: '<your organization unique name>',
  apiEndpoint: '<your api endpoint>',
  apiKey: '<your api key>',
  apiSecret: '<your api secret>',
  appBundle: '<your app bundle>',
));
await _aclSdkPlugin.registerDevice();
  • To map device with member
    • Note:
      1. Please make sure that you've already execute registerDevice at least one time before you call mapDeviceMember.
      2. Use this function whenever your app has memberId change event except logout (E.g: Login, Switch account,...)
import 'package:acl_sdk/acl_sdk.dart';

...

final _aclSdkPlugin = AclSdk();

...

await _aclSdkPlugin.mapDeviceMember('<your member id>');
  • To start collect data and location
await _aclSdkPlugin.startCollectData();
await _aclSdkPlugin.startCollectLocation();
  • To listen to Unified Intelligence server message
    • Note:
      1. You can use below sample code OR call aclFCMOnReceiveHandler directly in your custom handler. Therefore, don't worry if you've already had custom handler in your code.
      2. If you call aclFCMOnReceiveHandler in your existing handler, it should be better to add it at the first line of your function. Because, there might be some overlap event which handle by both side (our plugin and your app). This case rarely happen but still need you to aware about it.
      3. Our server message will always include type (in RemoteMessage.data) with following value: SYNC_DATA, DEVICE_CONFIG, TRAIN, SCORE.
import 'package:acl_sdk/work_manager_dispatchers/acl_fcm_on_receive_handler.dart';

...

// This line for background message handle (even when app killed)
FirebaseMessaging.onBackgroundMessage(aclFCMOnReceiveHandler);

// This line for foreground message handle
FirebaseMessaging.onMessage.listen(aclFCMOnReceiveHandler);

API #

  • To get device id
import 'package:acl_sdk/helpers/device_info_helper.dart';

...

final deviceId = await DeviceInfoHelper.generateDeviceId();
  • To check app usage access
import 'package:acl_sdk/helpers/permission_helper.dart';

...

final isAllowAppUsage = await PermissionHelper.isPackageUsageStatsEnable()
  • To open app usage setting
import 'package:acl_sdk/helpers/permission_helper.dart';

...

await PermissionHelper.goToAppUsageSetting();
  • To check notification bind listener access
import 'package:acl_sdk/helpers/permission_helper.dart';

...

await PermissionHelper.isNotificationListenerRunning();
  • To open setting notification bind listener
import 'package:acl_sdk/helpers/permission_helper.dart';

...

await PermissionHelper.goToNotificationListenerSetting();
  • To trigger sync data manually
import 'package:acl_sdk/helpers/sync_data_helper.dart';

...

await SyncDataHelper.syncData();
  • For location access please use package geolocator (recommend) or some other plugin that you prefer.

  • On iOS geolocator request permission might not work. Please

Notes #

  • When you handle request permission Location always on your app. Please check when user go back to app from setting, if user allow Location always, make sure you call await _aclSdkPlugin.startCollectLocation(); to start collect location immediately.

  • On iOS, we're pushing notification to topic sync_data in order to collect and synchronization data. Please make sure that you do not override this topic on your app.

Issues & Contribute #

Please file any issues, bugs or feature requests as an issue on our GitHub page. Commercial support is available, you can contact us at thanh@unified-intelligence.io

Author #

This acl_sdk plugin for Flutter is developed by Unified Intelligence

0
likes
150
points
82
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin which provide ACL functioning by Unified Intelligence. Which help you collect device's data and calculate device score.

Homepage

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

drift, drift_flutter, firebase_messaging, flutter, geolocator, http, intl, plugin_platform_interface, workmanager

More

Packages that depend on acl_sdk