SDK INTEGRATION DOCUMENTATION

Last updated: June 21, 2017

For any issues contact: iOS lead Gabriel Jensen at gabriel@xmodesocial.com

XModeAPI is a Cocoapod:

1. Add this line to your podfile. (Note: this has changed as of June 19, 2017)   

        pod 'XModeAPI' , ‘0.4.4’      

2. In AppDelegate.m, add:   

        #import <XModeAPI/XModeAPI.h>
           
        (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
        (NSDictionary *)launchOptions {

        [[XModeAPI sharedInstance] startWithApiKey:@"YOUR-API-KEY-HERE"];

NOTE: This will trigger the location permissions dialogue, so you may want to put this call after you have requested permissions from within your app.

The above will use Location Always On. If your app uses only Location While In Use, replace your call with

        [[XModeAPI sharedInstance] startWithApiKey:@"YOUR-API-KEY-
        HERE" isLocationInForegroundOnly:YES];     

3. Pass XModeAPI the user's email:

        [[XModeAPI sharedInstance] setEmailAddress:
        @"USERSEMAILHERE@USERSDOMAIN.COM"];         

4. Add an entry in your info.plist
   
        <key>NSBluetoothPeripheralUsageDescription</key>   
        <string>We use Bluetooth to enhance your location while in background</string>

5. If you are adding Location Always On to your app, add:

        <key>NSLocationAlwaysUsageDescription</key>        
        <string>This allows us to use your location to provide you certain features like         tracking movement more accurately, plus some other cool stuff.</string>        

Note: this text will never be seen by the user because we use BlueTooth only for location, but Apple will reject your app without it.        

6. In the Notes section of your app entry in itunesconnect, add this text so your app will be approved.        

        We are using both startMonitoringForRegion: and startRangingBeaconsInRegion:         for our beacon use. Beacons are meant to enhance location in the app. There is         no direct UI effect though, only better location. The app does NOT use Bluetooth         or CoreBluetooth directly. iBeacon only uses CoreLocation for region monitoring.

For any issues contact Android lead Justin Talia: justin@xmodesocial.com

The current version is 2.5.0

1. You will need two different strings that should be provided to you by our team:

        a. xmodeToken YOUR_XMODE_TOKEN
        b. apiKey YOUR_XMODE_API_KEY

2. In your (root) project build.gradle file, add the following lines (see lines in bold)

        buildscript {   
            repositories {       
                jcenter()   
            }

            dependencies {
                classpath 'com.android.tools.build:gradle:2.2.3'      
                classpath 'com.google.gms:google-services:3.0.0'   
            }
        }

        allprojects {   
            repositories {       
                jcenter()       
                maven {
                    url 'https://jitpack.io'                   
                        credentials {
                            username xmodeToken
                    }       
                } 
            }
        }

3. Create a reference to the xmodeToken in your (root) project’s gradle.properties file and add it to your project’s .gitignore for security. If it doesn’t exist, please create it and add the following line:

xmodeToken=YOUR_XMODE_TOKEN

4. If you are using proguard/dexguard, add the following:

        -dontwarn okio.**
        -keep class io.xmode.** {  *; }
        -keep class com.google.android.gms.** {  *; }
        -keepclassmembers class * implements android.os.Parcelable {   
            static ** CREATOR;
        }
        -keepclassmembers class * implements                 com.google.android.gms.common.internal.ReflectedParcelable {   
            static ** CREATOR;
       }

5. Also, in your app’s AndroidManifest.xml, please add the following to the inside of your <application …> tag:

        <meta-data   
          android:name="io.xmode.ApiKey"  
          android:value="YOUR_XMODE_API_KEY"/>

6. Add the following dependency to your application’s build.gradle file:

        compile 'com.github.xmodesocial:xmodesdk:2.5.0'

7. Go to your class that extends Application or MultiDexApplication and add the following:        

        public class MyApplication extends android.app.Application {                             @Override                   
            public void onCreate() {
                super.onCreate();                                   XModeSDK.init(getApplicationContext());                       
            }
        }

NOTE: Please do not initialize the XModeSDK from an asynctask, it should be called on its own in the onCreate method of your Application class as demonstrated above.