Download the "aar" file and add it to your project.
Project structure -> Dependency -> App Module -> Click + icon -> Provide your .aar file path -> click apply -> ok
Android studio will automatically add the dependency from your local aar file path and will sync your project. After finishing the sync, you are ready to use the Proximity SDK in your project
The following permissions are required in the application's Mainfest file for smooth working of the SDK services.
- android.permission.INTERNET
- android.permission.ACCESS_FINE_LOCATION
- android.permission.ACCESS_COARSE_LOCATION
- android.permission.FOREGROUND_SERVICE
- android.permission.ACCESS_BACKGROUND_LOCATION
- android.permission.ACTIVITY_RECOGNITION
Proximity SDK provides error codes with simple description. Developers can make use of the error code to meet the application logic.
//if another order-id is running in the background.
ANOTHER_ORDER_RUNNING(
errorCode = 0,
description = "Another Order ID is currently running. " +
"You can use forceInit=true for stop on going tracking and continue with this one."),
//if invalid organisation is passed to sdk
INVALID_ORGANISATION_ID(
errorCode = 1,
description = "Invalid organisation ID"),
//when sdk can't access the delivery
CANT_ACCESS_SERVER(
errorCode = 2,
description = "We are not able to connect to our servers." +
"Please try again later."),
//if sdk is not initialized using init method
SDK_N0T_INITIALIZED(
errorCode = 3,
description = "Please init SDK using Organisation ID " +
"before using SDK"),
//if order id is invalid
INVALID_ORDER_ID(
errorCode = 4,
description = "Please provide valid Order ID"),
//if the user is invalid
INVALID_USER_INFO(
errorCode = 5,
description = "Please provide valid User info"),
//for api success
SUCCESS(
errorCode = 6,
description = "Success"),
//for api error
ERROR(
errorCode = 7,
description = "Error"),
//when permission not enabled by the user
PERMISSION_NOT_ENABLED(
errorCode = 8,
description = "Location permission is not enabled");
Your application should register with Proximity SDK before invoking the location updates method. You need to pass the accessToken provided for your tenant to authorize the app for further usage. forceInit should be passed as true if you want to forcefully kill all the background tasks and create a new one. Default value will be false.
// Initialise Function
fun init(org : String, forceInit: Boolean = false, callbacks : CallBacks, isTestMode : Boolean = false)
//Implementation Example
import co.deliverysolutions.proximity.ProximitySDK // Import Proximity SDK package
lateinit var proximitySDKObject: ProximitySDK // Create Proximty SDK object
/*
this code will return error if any previous order is running.
you need to pass forceInit = true, if you want to forcefully registerfor new tracking.
*/
proximitySDK.init("<YOUR-ACCESS-TOKEN>", object : ProximitySDK.CallBacks{
override fun success(successMessage: String) {
var isTracking : Boolean = proximitySDK.isLocationServiceRunning() // you can determine the SDK status with this method.
// proceed further according to tracking Status value.
}
override fun onError(errorMessage: String) {
// If there is any error encountered by the SDK this callback will be triggered.
}
},isTestMode = true)
Note : Please proceed with next step only if this register function success call back is received.
fun startLocationUpdates(orderID : String,callbacks: CallBacks, /*optional*/ locationInterval : Long = 15000)
var orderID = "your order id"
proximitySDK
.startLocationUpdates(orderID, object : ProximitySDK.CallBacks{
override fun success(success: String) {
// On success the SDK will start updating location details.
}
override fun onError(error: String) {
// Any errors on updating location details to the proximity Server will be recived here.
// Any permission errors will also be recieved here.
}
},/*interval(optional)*/ 15000)
Note : This method will create a foreground service along with a notification for accessing background location if the application is killed.
import co.deliverysolutions.proximity.ProximitySDK.SDKUpdates
fun registerForSDKUpdates(sdkUpdates : SDKUpdates)
proximitySDK.registerForSDKUpdates(object : SDKUpdates{
override fun onStop(isStopped: Boolean) {
Toast.makeText(applicationContext,isStopped,Toast.LENGTH_LONG).show()
}
override fun permissionError(error: String) {
Toast.makeText(applicationContext,error,Toast.LENGTH_LONG).show()
}
override fun onError(error: String) {
Toast.makeText(applicationContext,error,Toast.LENGTH_LONG).show()
}
})
User vehicle information can be shared with the SDK, which will be updated along with the location updates service.
User vehicle information can be shared with the SDK, which will be updated along with the location updates service.
//Update Vehicle Info function
fun updateVehicleDetails(userInfo: UserInfo?,callbacks: CallBacks)
var userInfo = UserInfo(
vehicleColor = "Black",
isPickupBySomeoneElse = false,
contactNumber = "1234567890",
parkingSlot = "A1",
description = "Description",
vehicleNumber = "KL-11-AY-4545",
userName = "testuser",
vehicleMake = "Toyota",
vehicleType = "Sedan",
)
proximitySDK.updateVehicleDetails(orderID: String, userInfo,object : ProximitySDK.CallBacks{
override fun success(success: String) {
Toast.makeText(applicationContext,success,Toast.LENGTH_LONG).show()
finish()
}
override fun onError(error: String) {
Toast.makeText(applicationContext,error,Toast.LENGTH_LONG).show()
}
})
)
This method will forcefully stop location updates done by the SDK. Any pinned notification will also be removed from the notification bar.
proximitySDK.stopLocationUpdates()
This method will return a boolean value according to SDK tracking Status.
var isBackgroundServiceRunning = proximitySDK.isLocationServiceRunning()
In case user rejects the location permission, Proximity SDK have these methods to update the status of the user such as Estimated time of arival, Arrived status and Received status.
Estimated time of arival can be shared with SDK by using the below method.
fun updateETA(orderID: String, estimatedTime: String, callbacks: CallBacks)
proximitySDK.addETA(orderID = {orderID},
nowAsISO,object : CallBacks{
override fun success(success: String) {
Toast.makeText(applicationContext,success,Toast.LENGTH_LONG).show()
}
override fun onError(error: String) {
Toast.makeText(applicationContext,error,Toast.LENGTH_LONG).show()
}
})
Arrived Status can be shared with SDK using the below method.
fun setArrived(orderID: String, callbacks: CallBacks)
proximitySDK.setArrived(orderID = {orderID}, object : CallBacks{
override fun success(success: String) {
Toast.makeText(applicationContext,success,Toast.LENGTH_LONG).show()
}
override fun onError(error: String) {
Toast.makeText(applicationContext,error,Toast.LENGTH_LONG).show()
}
})
fun orderReceived(orderID: String, callbacks: CallBacks)
proximitySDK.orderReceived(orderID = {orderID}, object : CallBacks{
override fun success(success: String) {
Toast.makeText(applicationContext,success,Toast.LENGTH_LONG).show()
}
override fun onError(error: String) {
Toast.makeText(applicationContext,error,Toast.LENGTH_LONG).show()
}
})
Copyright (c) 2022 by Delivery Solutions. All Rights Reserved. Usage of this library implies agreement to abide by the license terms. Please refer to our Terms of Service.