Overview
The plugin is located at npmjs repositories (npm repositories)
This plugin is built for:
- Mobigate SDK version 1.0.4
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:
- Add to: android/settings.gradle
include ':react-native-mobigate'
project(':react-native-mobigate').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mobigate/android')
- Add to: android/app/build.gradle
dependencies {
implementation project(':react-native-mobigate')
}
- Add the MobigatePackage class to your list of exported packages into: android/app/src/main/.../MainApplication.java
...
import pl.spicymobile.reactmobigate.MobigatePackage;
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MobigatePackage()
);
}
Api methods
To use any method from the plugin add import:
import Mobigate from 'react-native-mobigate'
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)
Parameter | Type | Description |
---|
apiKey | String | Api key provided by your business partner |
options | Json Object | SDK configuration |
onSuccess | Function | returns callback object |
onError | Function | returns callback object |
Name | Type | Default | Description |
---|
appIdentifier | String | | Application identifier |
appInstallationSource | String | | App installation source e.g., google-play, organic. |
email | String | | Set's user email. |
customUserId | String | | You may use your custom userID for marking data. By default we are using device ID and emails for matching. Set it before starting the service using MobigateSDk.Builder method. |
enableUserFields | Json Array | | Enable custom fields in user data. By default MobienceSDK is gathering all identifiers, which it can read. You can choose one of these field: ["email", "imei", "imsi", "msisdn", "mac", "serial"] DODAĆ LINKA DO CONSTANTS. |
dataGatherPolicy | Json Object | | Enable custom data gater policy. By default MobienceSDK gather all data it can read and hide notification icon. Check below DataGatherPolicy options for more details. |
enableIdProfiles | Boolean | false | turns on / off the IDs profiles system. |
Name | Type | Default | Description |
---|
monitorState | String | | Possible monitor states: DODAĆ LINKA DO CONSTANTS. More info about gathering data here |
notificationText | String | | if state = Mobigate.DATA_GATHER_POLICY_DEFAULT you can pass custom foreground service notification text |
When the library is already initialized run it. Use startSDK(onSuccess, onError) method for that:
Mobigate.startSDK(onSuccess, onError)
Parameter | Type | Description |
---|
onSuccess | Function | returns callback object |
onError | Function | returns callback object |
initLibrary = () => {
if (Platform.OS === 'android') {
Mobigate.init("V0K6jhiIfem6CRWHYZ59Nmj3oFBBKbJsnSsWfR2JNq7ktblOUXwbJoBQTpWnw2uSwW76gpiu2kun50jweTY69B",
{
/*custom options, check docs for more details
appIdentifier: 'customUserAppIdentifier',
appInstallationSource: "customAppInstallationSourcexyz",
email: 'testemail@gmail.com',
userAgent: 'customUserAgent',
customUserId: 'customUserId',*/
}, (success) => {
/* You can configure custom collectors after init
Mobigate.disableAllDataCollector()
Mobigate.configureDataCollectors(true, [Mobigate.DATA_COLLECTOR_APPS_LIST,
Mobigate.DATA_COLLECTOR_BATTERY,
Mobigate.DATA_COLLECTOR_PHONE_INFO])*/
Mobigate.startSDK((result) => {
this.setState({
status: 'started',
});
}, (errorResult) => {
this.setState({
status: errorResult,
});
})
}, (initError) => {
this.setState({
status: initError,
});
})
}else{
this.setState({
status: 'Mobigate SDK supports only Android'
})
}
}
Tracking in app events
Overview
Implementation
Event categories
Event parameters
Remaining methods
Name | Type | Default | Description |
---|
| | | |
Constants
Sample app