public class UnbluVisitorApi
extends com.unblu.sdk.visitor.internal.InternalUnbluVisitorApi
Before using the API, ensure that in your app manifest file points you use either the class UnbluVisitorApplication
or a custom subclass of it for the application. Check its class documentation for further details.
If you want to use audio/video sessions, please ensure the following permissions are added to your manifest.xml
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Before calling any other function configureApi(UnbluApiConfiguration)
should be called inside main activity Activity.onCreate(Bundle)
.
The constants of IUnbluEventApi
can be used to register for events via a BroadcastReceiver
and access their values. The easier way is to subclass the UnbluEventReceiver
and override the methods according to the events which you want to listen for.
A typical flow for the usage would be:
Activity.onCreate(Bundle)
{
UnbluVisitorApi
.getInstance()
.UnbluCoreApi.configureApi(UnbluApiConfiguration)
//register for general errors and/or also other events
unbluBroadcastReceiver = new UnbluEventReceiver
(getApplicationContext()) {
...
//start the api. This could also be done later when it is needed, but it will take a while until the api is ready.
UnbluVisitorApi
.getInstance()
.UnbluCoreApi.initApi(IUnbluApiSuccessfullyInitializedCallback, IUnbluApiInitializeExceptionCallback)
(success: {<success handling>}, failure: {<error handling>}))
...
}
showUnblUi {
//the unblu UI should be shown
UnbluVisitorApi
.UnbluCoreApi.showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
(true, success: {<success handling>}, failure: {<error handling>});
}
ANIMATION_TIME, enableCapturingPerformanceLogging, enableDebugOutput
Modifier and Type | Method and Description |
---|---|
void |
configureApi(UnbluApiConfiguration configuration)
Configures the unblu api.
|
protected void |
destroy() |
static UnbluVisitorApi |
getInstance() |
void |
isAgentAvailable(IUnbluApiSuccessCallback<java.lang.Boolean> success,
IUnbluApiNotInitializedExceptionCallback failure)
Checks if at least one agent is available for co-browsing / chat.
|
void |
joinConversation(java.lang.String pin,
IUnbluApiSuccessCallback<java.lang.String> success,
com.unblu.sdk.core.internal.IUnbluApiInitConversationExceptionCallback failure)
Joins an unblu co-browsing session that was started by an agent.
|
void |
setConversationInterceptor(IConversationInterceptor conversationInterceptor)
Set the given conversation interceptor which is triggered for each new conversation.
|
void |
startConversation(ConversationType conversationType,
IUnbluApiSuccessCallback<java.lang.String> success,
com.unblu.sdk.core.internal.IUnbluApiInitConversationExceptionCallback failure)
Starts a new conversation with the given conversation type.
|
void |
startConversation(ConversationType conversationType,
java.lang.String visitorData,
IUnbluApiSuccessCallback<java.lang.String> success,
com.unblu.sdk.core.internal.IUnbluApiInitConversationExceptionCallback failure)
Starts a new conversation with the given conversation type.
|
getConversationInterceptor
deinitApi, getApplication, getCustomLoadingViewCreator, getLogLevel, getNotificationApi, getOpenConversationId, getPersonInfo, getUiBottomMargin, getUiTopMargin, getUnreadMessagesCount, initApi, initApi, internalGetCoreInstance, isCallUiOpen, isInErrorState, isInitialized, isUiVisible, openConversation, openConversationOverview, preloadUi, setApplicationContext, setAutoHideUiOnBack, setBackButtonCallback, setCustomBackgroundColor, setCustomCookies, setCustomLoadingViewCreator, setLogLevel, setNamedArea, setUiMargins, showUi, showUi, startAudioCall, startVideoCall
@NonNull public static UnbluVisitorApi getInstance()
UnbluVisitorApi
. Only for internal use!protected void destroy()
destroy
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<com.unblu.sdk.visitor.internal.VisitorApiDelegate>
public void configureApi(@NonNull UnbluApiConfiguration configuration)
UnbluCoreApi.initApi(IUnbluApiSuccessfullyInitializedCallback, IUnbluApiInitializeExceptionCallback)
to be able start new sessions and use other API features.
Note:
configureApi
in class com.unblu.sdk.visitor.internal.InternalUnbluVisitorApi
configuration
- The configuration for the unblu apijava.lang.IllegalStateException
- Thrown if the api was already initialized. The api needs to be deinitialized to configure it.public void startConversation(@NonNull ConversationType conversationType, @Nullable IUnbluApiSuccessCallback<java.lang.String> success, @Nullable com.unblu.sdk.core.internal.IUnbluApiInitConversationExceptionCallback failure)
UnbluCoreApi.showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
is needed to show the conversation.
This is an asynchronous call. Use the callbacks to check for success / failure.
conversationType
- The initial type of the new conversation.success
- Optional callback that will be called with the conversationId after the conversation was started and is display (if there is a UI).failure
- Optional callback if there was problem to start the conversation.public void startConversation(@NonNull ConversationType conversationType, @Nullable java.lang.String visitorData, IUnbluApiSuccessCallback<java.lang.String> success, com.unblu.sdk.core.internal.IUnbluApiInitConversationExceptionCallback failure)
UnbluCoreApi.showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
is needed to show the conversation.
This is an asynchronous call. Use the callbacks to check for success / failure.
startConversation
in class com.unblu.sdk.visitor.internal.InternalUnbluVisitorApi
conversationType
- The initial type of the new conversation.visitorData
- The visitor data of the new conversationsuccess
- Optional callback that will be called with the conversationId after the conversation was started and is display (if there is a UI).failure
- Optional callback if there was problem to start the conversation.public void joinConversation(@NonNull java.lang.String pin, @Nullable IUnbluApiSuccessCallback<java.lang.String> success, @Nullable com.unblu.sdk.core.internal.IUnbluApiInitConversationExceptionCallback failure)
This is an asynchronous call. Use the callbacks to check for success / failure.
joinConversation
in class com.unblu.sdk.visitor.internal.InternalUnbluVisitorApi
pin
- The pin of the conversation which shall be joined. (The pin is provided by the agent desk.)success
- Optional callback that will be called with the conversationId once the conversation was successfully joined.failure
- Optional callback that will be called if the conversation could not be joined.public void isAgentAvailable(@NonNull IUnbluApiSuccessCallback<java.lang.Boolean> success, @Nullable IUnbluApiNotInitializedExceptionCallback failure)
This is an asynchronous call. Use the callbacks to check for success / failure.
isAgentAvailable
in class com.unblu.sdk.visitor.internal.InternalUnbluVisitorApi
success
- Callback that will be called with true if at least one agent is available, false otherwise.failure
- Optional callback that will be called on failure.public void setConversationInterceptor(IConversationInterceptor conversationInterceptor)
setConversationInterceptor
in class com.unblu.sdk.visitor.internal.InternalUnbluVisitorApi
conversationInterceptor
- the specified conversation interceptor