1. Overview

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

  • Mobigate SDK version 1.0.4

2. Adding SDK to the project

First, install library from the repository with

yarn add react-native-mobigate

or

npm install react-native-mobigate --save

Link newly added plugin

  • React Native >= 0.60
    Starting from React Native 0.60, autolinking makes the installation process simpler
  • React Native <= 0.59
    • Mostly automatic installation:
      react-native link react-native-mobigate
    • Manual installation:

3. Api methods

To use any method from the plugin add import:

import Mobigate from 'react-native-mobigate'

3.1 SDK initialization

You must initialize the library before running it. Use init(apiKey, options, onSuccess, onError) method for that:

Mobigate.init(apiKey, options, onSuccess, onError)

ParameterTypeDescription
apiKeyStringApi key provided by your business partner
optionsJson ObjectSDK configuration 
onSuccessFunctionreturns callback object
onErrorFunctionreturns callback object

When the library is already initialized run it. Use startSDK(onSuccess, onError) method for that:

Mobigate.startSDK(onSuccess, onError) 

ParameterTypeDescription
onSuccessFunctionreturns callback object
onErrorFunctionreturns callback object

3.2 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.2.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, react-native-mobigate plugin contains recommended event categories and parameters via String constants (see Event categories and Event parameters).

3.2.2 Implementation

Tracking in-app events is performed by two methods:

Mobigate.trackEvent(options) 

Mobigate.trackAppInstall(timestamp)

ParameterTypeDescription
timestampdoubleUnix timestamp in milliseconds

3.2.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.2.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.3 Remaining methods

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


Mobigate.configureDataCollectors(enable, 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] 

Mobigate.disableAllDataCollector()
Disable all data collectors


Mobigate.setEmail(email)
Set user's email

NameTypeDescription
email String user's email address  

Mobigate.getEmail(onSuccess, onError)
Get previously set user email

NameTypeDescription
onSuccess Function returns callback object 
onError Function returns callback object

Mobigate.setFbToken(token)
Set fb token for social network collector

NameTypeDescription
token string facebook token

Mobigate.getSDKInfo(onSuccess, onError)
Getting information about the library

NameTypeDescription
onSuccess Function returns callback object 
onError Function returns callback object

Mobigate.getSDKUniqueIdentifier(onSuccess, onError)
Return unique SDK identificator

NameTypeDescription
onSuccess Function returns callback object 
onError Function returns callback object

Mobigate.getIDsProfiles(onSuccess, onError)
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

NameTypeDescription
onSuccess Function returns callback object 
onError Function returns callback object

Mobigate.getAdOceanTargeting(onSuccess, onError)
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

NameTypeDescription
onSuccess Function returns callback object 
onError Function returns callback object

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:

  • Mobigate.USER_FIELD_EMAIL
  • Mobigate.USER_FIELD_IMSI
  • Mobigate.USER_FIELD_IMEI
  • Mobigate.USER_FIELD_SERIAL

4.2 Data gather policy constants

Used to set how the library collects data:

  • Mobigate.DATA_GATHER_POLICY_DEFAULT
  • Mobigate.DATA_GATHER_POLICY_HIDE_TRAY
  • Mobigate.DATA_GATHER_POLICY_BLOCK_DATA_BG

4.3 Data collectors constants

Used to set which data the library should collect:

  • Mobigate.DATA_COLLECTOR_APPS_LIST
  • Mobigate.DATA_COLLECTOR_APPS_USAGE
  • Mobigate.DATA_COLLECTOR_BATTERY
  • Mobigate.DATA_COLLECTOR_BROWSER
  • Mobigate.DATA_COLLECTOR_CALENDAR_EVENTS
  • Mobigate.DATA_COLLECTOR_CPU_PROCESS
  • Mobigate.DATA_COLLECTOR_DICTIONARY
  • Mobigate.DATA_COLLECTOR_GEOLOCATION
  • Mobigate.DATA_COLLECTOR_HEADSET_PLUG
  • Mobigate.DATA_COLLECTOR_MEDIA_FILES
  • Mobigate.DATA_COLLECTOR_MEMORY_USEAGE
  • Mobigate.DATA_COLLECTOR_NETWORK_CONNECTION
  • Mobigate.DATA_COLLECTOR_NETWORK_USEAGE
  • Mobigate.DATA_COLLECTOR_PACKAGE_CHANGE
  • Mobigate.DATA_COLLECTOR_PHONE_INFO
  • Mobigate.DATA_COLLECTOR_ROAMING
  • Mobigate.DATA_COLLECTOR_SCREEN_ORIENTED
  • Mobigate.DATA_COLLECTOR_SIGNAL_STRENGTH
  • Mobigate.DATA_COLLECTOR_PROFILE_MODE
  • Mobigate.DATA_COLLECTOR_WIFI_DATA_CONNECTION
  • Mobigate.DATA_COLLECTOR_PERMISSION_COLLECTOR
  • Mobigate.DATA_COLLECTOR_NFC_COLLECTOR
  • Mobigate.DATA_COLLECTOR_BLUETOOTH_COLLECTOR
  • Mobigate.DATA_COLLECTOR_BLUETOOTH_DEVICES_COLLECTOR
  • Mobigate.DATA_COLLECTOR_MOVEMENT_COLLECTOR
  • Mobigate.DATA_COLLECTOR_FACEBOOK_NETWORK_COLLECTOR
  • Mobigate.DATA_COLLECTOR_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 add the prefix "CATEGORY_" or "PARAMETER_" to the category name or parameter e.g., Mobigate.CATEGORY_LEVEL_ACCOMPLISHED, Mobigate.CATEGORY_PURCHASE, Mobigate.PARAMETER_PRICE, Mobigate.PARAMETER_LEVEL.

5. Sample app

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

Tags:
Spicy Mobile
spicymobile.pl