Class Zendesk
-
- All Implemented Interfaces:
public final class Zendesk
Public entry point of the SDK. To use Zendesk out of the box you must call Zendesk.initialize first and once SuccessCallback is called the SDK instance will be available through Zendesk.instance.
Zendesk.initialize( context = context, channelKey = "{your-channel-key}", successCallback = { // The initialization was successful }, failureCallback = { cause -> // The initialization failed and "cause" is an optional "ZendeskError" } )
After Zendesk.initialize completes successfully, calling Zendesk.instance will return an instance of Zendesk which you can use to perform SDK actions such as showing the conversation screen.
Zendesk.instance.messaging.showMessaging(context)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
Zendesk.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Messaging
messaging
public final static Zendesk.Companion
Companion
-
Method Summary
Modifier and Type Method Description final Messaging
getMessaging()
final Unit
addEventListener(ZendeskEventListener listener)
Adds an instance of ZendeskEventListener to listen to all events emitted by the SDK. final Unit
removeEventListener(ZendeskEventListener listener)
Removes the given instance of ZendeskEventListener from the current listeners. final Unit
loginUser(String jwt, SuccessCallback<ZendeskUser> successCallback, FailureCallback<Throwable> failureCallback)
Authenticate a user. final Unit
logoutUser(SuccessCallback<Unit> successCallback, FailureCallback<Throwable> failureCallback)
Unauthenticate a user. final Unit
sendPageView(PageView pageView, SuccessCallback<Unit> successCallback, FailureCallback<Throwable> failureCallback)
Sends an event to the page view events API. final static Unit
initialize(Context context, String channelKey, SuccessCallback<Zendesk> successCallback, FailureCallback<Throwable> failureCallback, MessagingFactory messagingFactory)
Initializes Zendesk for the given channelKey, calling successCallback if the initialization completes successfully and failureCallback if it fails. final static Unit
initialize(Context context, String channelKey, SuccessCallback<Zendesk> successCallback, FailureCallback<Throwable> failureCallback)
Initializes Zendesk for the given channelKey, calling successCallback if the initialization completes successfully and failureCallback if it fails. final static Unit
invalidate()
Invalidates the current instance of Zendesk. -
-
Method Detail
-
getMessaging
final Messaging getMessaging()
-
addEventListener
final Unit addEventListener(ZendeskEventListener listener)
Adds an instance of ZendeskEventListener to listen to all events emitted by the SDK.
This method is safe for concurrent use.
- Parameters:
listener
- an instance of ZendeskEventListener to add
-
removeEventListener
final Unit removeEventListener(ZendeskEventListener listener)
Removes the given instance of ZendeskEventListener from the current listeners.
This method is safe for concurrent use.
- Parameters:
listener
- the instance of ZendeskEventListener to remove
-
loginUser
final Unit loginUser(String jwt, SuccessCallback<ZendeskUser> successCallback, FailureCallback<Throwable> failureCallback)
Authenticate a user.
- Parameters:
jwt
- The jwt belonging to the user.successCallback
- an implementation of SuccessCallback to be notified of a authentication resultfailureCallback
- an implementation of FailureCallback to be notified of a failure
-
logoutUser
final Unit logoutUser(SuccessCallback<Unit> successCallback, FailureCallback<Throwable> failureCallback)
Unauthenticate a user.
- Parameters:
successCallback
- an implementation of SuccessCallback to be notified of a un-authentication was successfulfailureCallback
- an implementation of FailureCallback to be notified of a failure
-
sendPageView
final Unit sendPageView(PageView pageView, SuccessCallback<Unit> successCallback, FailureCallback<Throwable> failureCallback)
Sends an event to the page view events API.
- Parameters:
pageView
- the page view event to sendsuccessCallback
- an implementation of SuccessCallback to be notified of a successful resultfailureCallback
- an implementation of FailureCallback to be notified of a failure
-
initialize
@JvmOverloads() final static Unit initialize(Context context, String channelKey, SuccessCallback<Zendesk> successCallback, FailureCallback<Throwable> failureCallback, MessagingFactory messagingFactory)
Initializes Zendesk for the given channelKey, calling successCallback if the initialization completes successfully and failureCallback if it fails. if a messagingFactory was provided an instance of Messaging will be created.
After a successful call to initialize, calling it again will simply call successCallback immediately.
This function is synchronized and won't run concurrently if called more than once at the same time.
- Parameters:
context
- an instance of Context.channelKey
- the key of your Messaging for Android channelsuccessCallback
- an implementation of SuccessCallback to be notified of a successful resultfailureCallback
- an implementation of FailureCallback to be notified of a failuremessagingFactory
- optional instance of MessagingFactory used to create instances of Messaging
-
initialize
@JvmOverloads() final static Unit initialize(Context context, String channelKey, SuccessCallback<Zendesk> successCallback, FailureCallback<Throwable> failureCallback)
Initializes Zendesk for the given channelKey, calling successCallback if the initialization completes successfully and failureCallback if it fails. if a messagingFactory was provided an instance of Messaging will be created.
After a successful call to initialize, calling it again will simply call successCallback immediately.
This function is synchronized and won't run concurrently if called more than once at the same time.
- Parameters:
context
- an instance of Context.channelKey
- the key of your Messaging for Android channelsuccessCallback
- an implementation of SuccessCallback to be notified of a successful resultfailureCallback
- an implementation of FailureCallback to be notified of a failure
-
invalidate
final static Unit invalidate()
Invalidates the current instance of Zendesk.
After calling this method you will have to call Zendesk.initialize again if you would like to use Zendesk.
-
-
-
-