> For the complete documentation index, see [llms.txt](https://docs.mfilterit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mfilterit.com/mfilterit-sdk/mfilterit-react-native-integration-1.md).

# mFilterIt React-Native Integration

This guide details the steps to integrate the MFilterIt SDK into a react-native Android App

## Getting Started <a href="#getting-started" id="getting-started"></a>

Integrating the mFilterIt Solution into an app includes Developer Registration and SDK integration.

## Developer Registration <a href="#developer-registration" id="developer-registration"></a>

Developers wishing to use mFilterIt should first register themselves. Upon registration, a unique vendor ID will be allocated.

Please contact us to initiate the registration, at <contact@mfilterit.com>

## SDK Integration <a href="#sdk-integration" id="sdk-integration"></a>

The SDK integration can be done by adding the SDK jar to the project.

&#x20;**Step 1** : The SDK is made available as a jar archive . This archive needs to be included into App project.

**Step 2** : Provide permissions to the SDK The mFilterIt SDK requires the following permissions to be granted in the Android manifest file

| Permission               | Level     | Description                                              |
| ------------------------ | --------- | -------------------------------------------------------- |
| ACCESS\_NETWORK\_STATE   | Mandatory | Allows applications to access information about networks |
| READ\_PHONE\_STATE       | Mandatory | Allows read only access to phone state.                  |
| INTERNET                 | Mandatory | Allows access to the internet                            |
| WRITE\_EXTERNAL\_STORAGE | Optional  | Allows write into external storage area                  |
| ACCESS\_WIFI\_STATE      | Optional  | Allows application to query Wifi state                   |
| GET\_ACCOUNTS            | Optional  | Allows application to access Google accounts data        |
| READ\_CALL\_LOG          | Optional  | Allows an application to read the user's call log        |
| READ\_SMS                | Optional  | Allows an application to read SMS messages.              |
| READ\_CONTACTS           | Optional  | Allows an application to read the user's contacts data.  |

The mFilterIt algorithm works most efficiently when all permissions are allowed. However, the SDK is able detect some fraudulent activity with the mandatory permissions itself.

**Step 3** : Insert the following lines inside the dependencies block in android/app/build.gradle :&#x20;

```
compile files('$PATH$/Mfilterit_SDK_latest_p.jar')
```

Here $PATH$ is the file path of jar file relative to root path.

**Step 4** : Open up android/app/src/main/java/\[...]/MainApplication.java and add the following line to imports (at the top of the file):

![](https://54224591-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LA9heZnVVfp19--pSPs%2F-LOMbxRfBazdhxgDnn8k%2F-LOMdlAQ8burLghU0fIq%2Fb6ac28ec-a0fd-4de0-8daa-58ead60b1636.jpg?alt=media\&token=7fe0de02-3425-479d-a0b2-828b05e36b4c)

```
import com.mfilterit.MFilterIt;
```

**Step 5** : Initialize the SDK, The SDK is initialized by invoking the sdkInit API. This should be done in the OnCreate routine of the MainApplication.java. sdkInit is invoked as shown below The below is a description of the parameters taken by the sdkInit Routine.

```
MFilterIt.sdkInit(Context context, String vendorId, int extDataPoints);
```

| Parameter     | Description                                                                                                                                                                                                                               |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| context       | Context object returned by getApplicationContext                                                                                                                                                                                          |
| vendorId      | This is a unique Vendor ID string allocated to the app developer. The Vendor ID is provided to you at registration, and is critical to identify the server side endpoint. Please contact us for the Vendor ID, at <contact@mfilterit.com> |
| extDataPoints | Set to "MfilterIt.DATAPOINTS\_LEVEL\_1"                                                                                                                                                                                                   |

A code snippet of a sample OnCreate is captured below

```
@Override
  public void onCreate() {
    super.onCreate();
    MFilterIt.sdkInit(getApplicationContext(), "vendorId", MFilterIt.DATAPOINTS_LEVEL_1 );
  }
```

&#x20;**Points to remember :**                                                                                                     1. For Android 6.0+ devices, please take the mandatory permissions from the user before the SDK is triggered. The SDK does not take any permissions on its own, and depends on the app to take the needed permissions before hand.

2\. Please update the following in proguard rules file ( in case of encrypted jar uses):&#x20;

```
-keep public class com.mfilterit.{ ; } 
-keep public class com.a.e.{ ; }
```
