Intouch Android SDK
Introduction
Get Real-Time Location Tracking for your apps with MapmyIndia InTouch SDK. Track a user's live location with our simplified InTouch SDK integration (for Android), highly customizable to your specific needs.
The InTouch SDK comes with a variety of events that enable better control and power over your tracking needs. Get ready made events to create,, Geo-Fences, Event Alerts, and Trails of telematics/ phone devices. Also get location benefits built for various applications including logistics, delivery tracking, employee tracking, and live location sharing.
To get started, explore the InTouch Demo App.
Already have an application? Give it a boost with the powerful features of InTouch. Learn how to Integrate the InTouch SDK
- Setup: Please contact apisupport@mapmyindia.com to get the Intouch SDK authorisation for your Client ID and Client Secret.
- Quick Start: Start with a ready-to-go app
- Integrate the SDK: Integrate the SDK into your app
- Dashboard: See all your devices' locations on MapmyIndia InTouch Dashboard
- InTouch Telematics APIs: Use InTouch APIs to get the details of the devices.
Setup.
We use your Client ID to identify your account details and assign all your user's devices under a single account.
To get your Outh2 Rest API Client ID and Client Secret please login to MapmyIndia API Dashboard
Please contact apisupport@mapmyindia.com to get InTouch SDK access to your Client ID
After getting the access, you can start with the InTouchDemo app, or Integrate the InTouch SDK in your app.
InTouchDemo app
This guide allows you to add live location tracking to an Android app. Android Studio is the recommended development environment for building an app with the MapmyIndia InTouch SDK for Android.
Step 1. Download the InTouchDemo App.
Click here to download the InTouchDemo App Project. Open this project in Android Studio
Step 2. Set your Publishable key
- Add the publishable key to SetUpKeyFragment Fragment file.
- Run project on your device using simulator instance.
- Go through run-time permission flow (applicable for Android M and later).
Step 3. Check your location on the InTouch dashboard
Integrate the InTouch SDK
Step 1: Setup a project
- Start Android Studio.
- Create a new project as follows:
- If you see the Welcome to Android Studio dialog, choose Start a new Android Studio project, available under 'Quick Start' on the right of the dialog.
- Otherwise, click File in the Android Studio menu bar, click New-> New Project.
- Select the form factors you need for your app. If you're not sure what you need, just select Phone and Tablet.
- Select Add No Activity and click Next.
- Enter your app name, package name, project location, language and minimum API version as prompted. Click Next.
- Create a Basic Activity in the 'Add an activity to Mobile' dialog. Click Next.
- Enter the activity name, layout name and title as prompted. Click Finish.
Android Studio starts Gradle and builds your project. This may take a few seconds. For more information about creating a project in Android Studio, see the Android Studio documentation.
The next few sections contain the code samples that you need to add to your activity's java file as well as its xml layout file for creating an app with MapmyIndia InTouch SDK for live tracking.
Step 2. Add InTouch SDK
Follow these steps to add the SDK to your project –
- Create a new project in Android Studio
- Add MapmyIndia repository in your project level
build.gradle
allprojects {
repositories {
maven {
url 'https://maven.mapmyindia.com/repository/mapmyindia/'
}
}
}
- Add below dependency in your app-level
build.gradle
implementation 'com.mapmyindia.sdk:intouch-sdk:0.9.4'
Add Java 8 Support to the project
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
Required Minimum sdk version
minSdkVersion 18
Step 3: Initialize InTouch SDK
Initialization can be done either of the below mentioned method. Keep the same method accross your project.
Method 1:
Initialize the SDK without unique Id. Intouch SDK will create a unique Id for the device. On every new device Login , a new device will be created and the new device id will be returned.
Java
// IAuthListener - returns authorization results in the forms of callbacks.
InTouch.initialize(<device name>, <your client id>, <your client secret>, new IAuthListener() {
@Override
public void onSuccess(Long id) {
//write your code here
}
@Override
public void onError(String reason, String identifier, String description) {
// reason gives the error type.
// errorIdentifier gives information about error code.
// errorDescription gives a message for a particular error.
}
});
Kotlin
InTouch.initialize(<device name>, <your client id>, <your client secret>, object : IAuthListener {
override fun onSuccess() {
//write your code here
}
override fun onError(reason: String?, errorIdentifier: String?, errorDescription: String?) {
// reason gives the error type.
// errorIdentifier gives information about error code.
// errorDescription gives a message for a particular error.
}
})
or
Method 2:
Initialize the SDK with your own Unique Id. It is recommended to use when you maintain the unique Id for your users. Now when ever this Unique Id is passed same device id will be returned in the response, even if the user s logs from different devices.
Java
// IAuthListener - returns authorization results in the forms of callbacks.
InTouch.initialize(<device name>, <your client id>, <your client secret>, <uniqueId>, <fcmToken>, new IAuthListener() {
@Override
public void onSuccess(Long id) {
//write your code here
}
@Override
public void onError(String reason, String identifier, String description) {
// reason gives the error type.
// errorIdentifier gives information about error code.
// errorDescription gives a message for a particular error.
}
});
Kotlin
InTouch.initialize(<device name>, <your client id>, <your client secret>, <uniqueId>, <fcmToken>, object : IAuthListener {
override fun onSuccess(Long entityId) {
//write your code here
}
override fun onError(reason: String?, errorIdentifier: String?, errorDescription: String?) {
// reason gives the error type.
// errorIdentifier gives information about error code.
// errorDescription gives a message for a particular error.
}
})
On sucessful registration you will get the Id, use this Id in APIs to get the live location or to create trips against the user.
Step 4: Start Tracking
Track your app user's phone live location by using the below method.
Java
InTouch.startTracking();
Kotlin
InTouch.startTracking
Step 4: Stop Tracking
Java
InTouch.stopTracking();
Kotlin
InTouch.stopTracking