​Zoho Assist Callbacks
Use the SDK callbacks methods in the ISessionCallbacks class to override these methods to suit your app.
class ISessionCallbacks(private val activity: Activity, private val binding: ActivityMainBinding) :
SessionCallbacks {
/**
* Callback used to perform any operation using the response gotten from validating the token and session key.
*/
override fun onValidationResponse(response: String, responseCode: AssistSession.ApiResponse) {
Toast.makeText(activity, response, Toast.LENGTH_SHORT).show()
when (responseCode) {
AssistSession.ApiResponse.SUCCESS -> {
}
AssistSession.ApiResponse.ERROR -> {
}
}
}
/**
* Callback used to handle why the session failed scenario cases
*/
override fun onSessionStartFailed(failure: SessionStartFailure) {
when (failure) {
SessionStartFailure.BELOW_MIN_API_LEVEL -> {}
SessionStartFailure.CONTEXT_NOT_AVAILABLE -> {}
SessionStartFailure.INVALID_SDK_TOKEN -> {}
SessionStartFailure.INVALID_SESSION_KEY -> {}
SessionStartFailure.POST_NOTIFICATION_PERMISSION_DENIED -> {}
else -> {}
}
}
/**
* Called when AddOn is available for the device via playstore.
* Can be used by the customer to install the plugin from their own sources if necessary.
*/
override fun onAddOnAvailableForDownload() {
}
/**
* Callback used to handle the received messages.
*/
override fun onMessageReceived(model: ChatModel) {
}
/**
* Callback used to handle UI changes for role change request.
*/
override fun onRoleChangeRequest() {
}
/**
* Callback used to handle screenshare request
*/
override fun onScreenShareRequest() {
}
/**
* Callback used to perform any operation when session ends.
*/
override fun onSessionEnded() {
}
/**
* Callback used to perform any operation when session starts.
*/
override fun onSessionStarted() {
}
/**
* Called when screen share is started, and can be used in conjunction
* with `startRemoteControlOnStart(false)` to prompt user for remote control permission
*/
override fun onScreenShareStarted() {
// AssistSession.INSTANCE.startAddon()
}
/**
* Called when participant status changes
*/
override fun onParticipantStateChange(
participantState: ParticipantState,
participantName: String
) {
}
Service Queue unit
1. To enroll the device, use the below function.
AssistSession.INSTANCE.enrollDevice(BaseUrl.COM, callback = object :EnrollmentCallback{
override fun onEnrollmentSuccess() {
//Enable the Service Queue request button or show it (visibility set to VIEW).
//Handle your UI based on the result
}
override fun onEnrollmentFailure(exception: String) {
//Handle your UI based on the result
}
})
2. To un-enroll the device, use the below function.
AssistSession.INSTANCE.unenroll(object : UnenrollmentCallback {
override fun onUnenrollmentSuccess() {
//Disable the Service Queue request button or hide it (visibility set to GONE).
//Handle your UI based on the result
}
override fun onUnenrollmentFailure(exception: Exception) {
//Handle your UI based on the result
}
})
3. To get the enrollment state, use the below function.
AssistSession.INSTANCE.isEnrolled(context = this)
4. To check if the active request is in the Service Queue, use the below function.
AssistSession.INSTANCE.hasActiveServiceQueue()
5. To request a Service Queue call, use the below function.
//The description must not be empty and Description length should not exceed 500 characters.
AssistSession.INSTANCE.requestServiceQueue("your description","Your company name", serviceQueueCallBack = object : ServiceQueueCallBack {
override fun requestResponse(request: Request) {
when(request){
Request.SUCCESS -> {
// Handle your UI based on the result
}
Request.FAILURE -> {
// Handle your UI based on the result
}
Request.IN_QUEUE -> {
// Handle your UI based on the result
}
}
}
})
6. To use foreground service for ServiceQueue connection. You should add it in the application tag of the app manifest file.
<service
android:name="com.zoho.unattendedaccess.connectivity.ConnectivityService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="dataSync"
android:stopWithTask="false"/>