1. Overview

The plugin is located at pub repositories (pub repositories)
This plugin is built for:

  • Mobigate SDK version 1.0.6

2. Adding SDK to the project

First, add this to your package's pubspec.yaml file

dependencies:
  flutter_mobigate: ^1.0.2

Install packages from the command line

$ flutter pub get

3. Api methods

To use any method from the plugin add import:

import 'package:flutter_mobigate/flutter_mobigate.dart';

3.1 MobigateSDK class initialization

Initialize class with MobigateSDK(MobigateOptions options)

MobigateOptions(apiKey,{appIdentifier, appInstallationSource,email,cusUserId,enableUserFields,dataGatherPolicy,notificationText,enableIdProfiles})

3.2 SDK initialization

You must initialize the library before running it. Use Future<String> init method for that:

mobigateInstance.init()

Return:

MessageTypeDescription
successStringreturns success message
errorStringreturns error message

When the library is already initialized run it. Use Future<String> startSdk() method for that:

mobigateInstance.startSdk(); 

Return:

MessageTypeDescription
successStringreturns success message
errorStringreturns error message

3.3 Tracking in app events

In-App Events provide insight on what is happening in your app. It is recommended to take the time and define the events you would like to measure.

3.3.1 Overview

An event consists of two fields that you  can use to describe a user's interaction with your app content:

Field nameTypeRequiredDescription
CategoryStringyesEvent category
ParameterStringnoEvent parameter. 
There can be more than one

You can use any event category or parameter string of your choice. However, flutter_mobigate plugin contains recommended event categories and parameters via String constants (see Event categories and Event parameters).

3.3.2 Implementation

Tracking in-app events is performed by two methods:

void trackEvent(Category category) 

ParameterTypeDescription
CategoryCategory class Category class built with help of CategoryBuilder

void trackAppInstall(int timestamp)

ParameterTypeDescription
timestampdoubleUnix timestamp in milliseconds

3.3.3 Event categories

The following section describes the recommended structure of each event category. In-app events categories are defined as part of plugin String constants.

3.3.4 Event parameters

In addition each category that is passed with event may have optional parameters defined as part of the plugin constants, or custom defined as String. Below is a list of recommended parameters.

3.4 Remaining methods

void setCollectAll()
This method enables all data collectors. By default all data collectors are enabled.


void configureDataCollectors(bool enable, List<int> collectors)
Enable or disable DataCollector by array collectors input

NameTypeDescription
enablebooleantrue if enable, false if disable
collectorsarray of data collector conste.g.,[Mobigate.DATA_COLLECTOR_BATTERY, DATA_COLLECTOR_GEOLOCATION]

void disableAllDataCollector()
Disable all data collectors


void setEmail(String email)
Set user's email

NameTypeDescription
email String user's email address

Future<String> getEmail()
Get previously set user email. Return email on success, error otherwise.


void setFbToken(String token)
Set fb token for social network collector

NameTypeDescription
token string facebook token

Future<String> getSDKInfo()
Getting information about the library. Return on success sdk info string, error otherwise.


Future<String> getSDKUniqueIdentifier()
Return unique SDK identificator. Return on success sdk unique identifier, error otherwise.


Future<List<int>> getIDsProfiles()
Method returns IDs profiles. List of IDs profiles in the application memory is updated (synchronized with the server) at specified intervals. To enable functionality, use the 'enableIDsProfiles (boolean enable)' method. Returns the identifiers of IDs profiles (ex. 5,9,20), returns '0' if list of user IDs profiles is empty, returns 'null' if the system has not yet communicated


Future<Map<String, int>> getAdOceanTargeting()
Getting numerical variables, that can be used for ads targeting. Method must be called from separate thread. Return 3 different identifiers of a user, encoded into a map of AdOcean numerical variables

4. Constants

The plugin provides many helpful constants for easier implementation.

4.1 User field constants

Used to set custom user fields inside Mobigate.init() method:

  • UserField.USER_FIELD_EMAIL
  • UserField.USER_FIELD_IMSI
  • UserField.USER_FIELD_IMEI
  • UserField.USER_FIELD_SERIAL

4.2 Data gather policy constants

Used to set how the library collects data:

  • MonitorState.DATA_GATHER_POLICY_DEFAULT
  • MonitorState.DATA_GATHER_POLICY_HIDE_TRAY
  • MonitorState.DATA_GATHER_POLICY_BLOCK_DATA_BG

4.3 Data collectors constants

Used to set which data the library should collect:

  • DataCollector.APPS_LIST
  • DataCollector.DATA_COLLECTOR_APPS_USAGE
  • DataCollector.BATTERY
  • DataCollector.BROWSER
  • DataCollector.CALENDAR_EVENTS
  • DataCollector.CPU_PROCESS
  • DataCollector.DICTIONARY
  • DataCollector.GEOLOCATION
  • DataCollector.HEADSET_PLUG
  • DataCollector.MEDIA_FILES
  • DataCollector.MEMORY_USEAGE
  • DataCollector.NETWORK_CONNECTION
  • DataCollector.NETWORK_USEAGE
  • DataCollector.PACKAGE_CHANGE
  • DataCollector.PHONE_INFO
  • DataCollector.ROAMING
  • DataCollector.SCREEN_ORIENTED
  • DataCollector.SIGNAL_STRENGTH
  • DataCollector.PROFILE_MODE
  • DataCollector.WIFI_DATA_CONNECTION
  • DataCollector.PERMISSION_COLLECTOR
  • DataCollector.NFC_COLLECTOR
  • DataCollector.BLUETOOTH_COLLECTOR
  • DataCollector.BLUETOOTH_DEVICES_COLLECTOR
  • DataCollector.MOVEMENT_COLLECTOR
  • DataCollector.FACEBOOK_NETWORK_COLLECTOR
  • DataCollector.ROOT_COLLECTOR

4.4 Category and parameter constants

Instead of using defined categories or parameters in the form of text, you can use constants defined in the plugin. All you have to do is use EventCategory or EventParameter class e.g., EventCategory.LEVEL_ACCOMPLISHED, EventCategory.PURCHASE, EventParameter.PRICE, EventParameter.LEVEL.

5. Sample app

The sample application is located in the github repository here in example folder.

Tags:
Spicy Mobile
spicymobile.pl