SDK Integrations

Introduction

NearX supports a number of out-of-box server-side integrations with popular CRMs, Marketing Management products and Location Management tools.

Android SDK/ARR Integration

Note: Please generate APIKEY by logging into our console

SDK

Steps to integrate NearX SDK into your Android app

  1. Open your app in Android Studio

  2. Open build.gradle of Project and add this code

        allprojects {
            repositories {
                maven {
                    url "https://jitpack.io"
                }
        }
  3. Open build.gradle of Module:app and add the below code

       dependencies{
           implementation 'com.github.nearxgetwalk:nearx:1.0'
       }
  4. Ensure your app is asking for below mentioned permissions in AndroidManifest.xml

        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  5. Now in your app’s AndroidManifest.xml, add the following lines

         <receiver          android:name="in.walkin.nearxsdk.geofence.GeofenceEventBroadcastReceiver"
              android:enabled="true"
              android:exported="true">
        </receiver>
        <service android:name="in.walkin.nearxsdk.geofence.GeofenceTransitionsJobIntentService"
              android:exported="true"
              android:permission="android.permission.BIND_JOB_SERVICE"/>
  6. Ask for Location Permission in the runtime.

  7. Initialize the SDK with method methods.

        /* For Initialization */
        NearX nearx = new NearX(activity:this);
    
        /* Invoke below method for better detection in any of the below mobiles which would ask for auto-start permission */
        /* Xiomi, Oppo, Vivo, Letv, Honor, Huawei, Asus */
        nearx.checkHandset();
    
        /* Save user details by invoking below method */
        String mobileNumber = "987654321"
        String name = "UserName"
        String authKey = "<AUTH_KEY_GENERATED_FROM_WEBSITE>"
        nearx.saveUser(mobileNumber,name,authKey);
    
        /* You can fetch the saved user details seperately using below methods */
        nearx.getPhoneNumber();
        nearx.getUserName();
        nearx.getAuthKey();
    
        /* Additional features */
        // Test GPS Status
        nearx.testGpsStatus();
    
        //Re-register without changing user details   
        nearx.reRegister(authKey,activity:this);

ARR

Steps to integrate NearX ARR into your Android app

  1. Download the ARR file here

  2. Goto File -> New -> New Module -> Import .JAR/.AAR Package.

  3. Locate your path of AAR file and add Project Name. Example: nearxsdk-release. Click Next.

  4. Open build.gradle of Module:app and add the below code

       dependencies{
           implementation project(path: ':nearxsdk-release')
       }
  5. Ensure your app is asking for below mentioned permissions in AndroidManifest.xml

        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  6. Now in your app’s AndroidManifest.xml, add the following lines

         <receiver          android:name="in.walkin.nearxsdk.geofence.GeofenceEventBroadcastReceiver"
              android:enabled="true"
              android:exported="true">
        </receiver>
        <service android:name="in.walkin.nearxsdk.geofence.GeofenceTransitionsJobIntentService"
              android:exported="true"
              android:permission="android.permission.BIND_JOB_SERVICE"/>
  7. Ask for Location Permission in the runtime.

  8. Initialize the SDK with method methods.

        /* For Initialization */
        NearX nearx = new NearX(activity:this);
    
        /* Invoke below method for better detection in any of the below mobiles which would ask for auto-start permission */
        /* Xiomi, Oppo, Vivo, Letv, Honor, Huawei, Asus */
        nearx.checkHandset();
    
        /* Save user details by invoking below method */
        String mobileNumber = "987654321"
        String name = "UserName"
        String authKey = "<AUTH_KEY_GENERATED_FROM_WEBSITE>"
        nearx.saveUser(mobileNumber,name,authKey);
    
        /* You can fetch the saved user details seperately using below methods */
        nearx.getPhoneNumber();
        nearx.getUserName();
        nearx.getAuthKey();
    
        /* Additional features */
        // Test GPS Status
        nearx.testGpsStatus();
    
        //Re-register without changing user details
        nearx.reRegister(authKey,activity:this);

iOS SDK Integration

Note: Enable AppDelegate to start listening to location events

Steps to integrate NearX SDK into your iOS app

  1. Integrate the Cocoapod here

  2. Open AppDelegate.swift and add interface CLLocationManagerDelegate to start listening to location events.

  3. In the didFinishLaunchingWithOptions function, you need to add the following code

        locationManager.delegate = self
        locationManager.requestAlwaysAuthorization()
  4. Override methods of locationManager that listens to geofence events

        func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
            GeofenceUtils.sendGeofenceEvent(
                eventType: GeofenceUtils.GEOFENCE_ENTRY, 
                locationName: "\(region.identifier)"
            )
        }
        func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
            GeofenceUtils.sendGeofenceEvent(
                eventType: GeofenceUtils.GEOFENCE_EXIT, 
                locationName: "\(region.identifier)"
            )
        }
  5. Go to Info.plist and set values for NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription.

  6. Initialize NearX SDK and send it relevant information

  7. Whenever you want to start NearX (typically after user reqistration), you can add the following code in your ViewController

        //Username of the user (optional)
        GeofenceUtils.setName(name: username)
        //Mobile Number of the user (compulsory)
        GeofenceUtils.setMobileNumber(mobileNumber: mobile)
        //Fcmtoken of the user (optional)
        GeofenceUtils.setFCMToken(fcmToken: token)
        //AuthKey for your project (This can be created in NearX Console)
        GeofenceUtils.setAuthKey(authKey:authKey)
  8. Initialize Geofences

        let geofence = Geofence()
        geofence.initializeGeofences()

Support

Have questions after reading the documentation? Contact us here