Example Code
Example App using the SDK
https://github.com/bringg/DriverSdkCustomerExample-Android
Initialization
// creating custom settings
val settings = SdkSettings.Builder()
.autoArriveByLocation(true)
.autoLeaveByLocation(true)
// sdk init
val sdkClient = ActiveCustomerSDKFactory.init(
context,
NotificationProviderImpl(context),
settings.build()
)
val userLogoutCallback = object : UserLogoutCallback {
override fun onLoggedOut() {
Log.d(TAG, "user logged out")
}
}
sdkClient.setUserLogoutCallback(userLogoutCallback)
// observe login state
sdkInstance.isLoggedIn().observe(this, Observer { isLoggedIn -> onLoginStateChanged(isLoggedIn) })
// observe online state
sdkInstance.isOnline().observe(this, Observer { isOnline -> onOnlineStateChanged(isOnline) })
// observe active user order and states (start/arrive/left/done)
sdkInstance.activeTask().observe(this, Observer { onActiveOrderChanged(it) })
Login
// login
customerActions.login(token, secret, region, object : ResultCallback<LoginResult> {
override fun onResult(result: LoginResult) {
Log.i(TAG, "login result=$result, success=${result.success()}")
}
})
Pickup Flow
The taskId param in the following examples is the id you obtain from bringg servers after creating the task.
// start the task
customerActions.startTask(taskId, object : ResultCallback<StartTaskResult> {
override fun onResult(result: StartTaskResult) {
Log.i(TAG, "order start result=$result, success=${result.success()}")
}
})
// arrive (manually)
val result = customerActions.arriveToWaypoint()
Log.i(TAG, "arrive result=$result, success=${result.success()}")
// leave (manually)
val result = customerActions.leaveWaypoint()
Log.i(TAG, "leave result=$result, success=${result.success()}")
Example Flow in a Gif
The Following shows a very basic ui that interacts with the SDK to go through the whole flow.
Updated over 2 years ago