public abstract class UnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
extends com.unblu.sdk.core.internal.InternalUnbluCoreApi<T>
Minumum Requirements:
Android API version 23
Collaboration server 6.33.x or newer.
Modifier and Type | Field and Description |
---|---|
static long |
ANIMATION_TIME
The time used for the fade in and fade out animation when showing/hiding the UI
|
static boolean |
enableCapturingPerformanceLogging
Enables logging of capturing performance (e.g.
|
static boolean |
enableDebugOutput
Enables the debug output of the Unblu SDK.
|
Modifier | Constructor and Description |
---|---|
protected |
UnbluCoreApi(T apiDelegate) |
Modifier and Type | Method and Description |
---|---|
void |
configureApi(UnbluApiConfiguration configuration)
Configures the unblu api.
|
void |
deinitApi(IUnbluApiSuccessVoidCallback success,
IUnbluDeinitializeExceptionCallback failure)
Deinitializes the unblu API.
|
android.app.Application |
getApplication()
Returns the application context object
|
IUnbluCustomLoadingViewCreator |
getCustomLoadingViewCreator()
Returns the currently configured loading view creator
|
static LogLevel |
getLogLevel()
Returns the log level of the Unblu SDK.
|
static IUnbluNotificationApi |
getNotificationApi()
Returns the low level notification API which can be used if the unblu firebase notification module is not used.
|
java.lang.String |
getOpenConversationId()
Returns the id of the currently opened conversation inside the UI.
Null if no conversation is open |
PersonInfo |
getPersonInfo()
Returns the info of the current person
|
int |
getUiBottomMargin()
Returns the current bottom margin of the unblu Ui
|
int |
getUiTopMargin()
Returns the current top margin of the unblu Ui
|
int |
getUnreadMessagesCount()
Returns the number of unread messages
|
void |
initApi(android.app.Activity activeActivity,
IUnbluApiSuccessfullyInitializedCallback success,
IUnbluApiInitializeExceptionCallback failure)
Inits the unblu API.
|
void |
initApi(IUnbluApiSuccessfullyInitializedCallback success,
IUnbluApiInitializeExceptionCallback failure)
Inits the unblu API.
|
static <D extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate> |
internalGetCoreInstance() |
void |
isCallUiOpen(IUnbluApiSuccessCallback<java.lang.Boolean> success,
IUnbluApiNotInitializedExceptionCallback failure)
Checks if the call UI for an audio/video call is open or not.
|
boolean |
isInErrorState() |
boolean |
isInitialized() |
boolean |
isUiVisible()
Checks if the UI is visible or not
|
void |
openConversation(java.lang.String conversationId,
IUnbluApiSuccessVoidCallback success,
IUnbluApiOpenConversationExceptionCallback failure)
Opens the conversation for the given id.
The unblu UI must have been visible at least once. |
void |
openConversationOverview(IUnbluApiSuccessVoidCallback success,
IUnbluApiOpenConversationOverviewExceptionCallback failure)
Opens the overview over all conversations.
The unblu UI must have been visible at least once. |
void |
preloadUi(IUnbluApiSuccessVoidCallback success,
IUnbluApiNotInitializedExceptionCallback failure)
Starts pre loading the chat ui.
|
void |
setApplicationContext(android.app.Application application)
Set the application.
|
void |
setAutoHideUiOnBack(boolean autoHideUiOnBack)
If set to true, the unblu UI will hide automatically if the user presses the back button and there is no more navigation inside the unblu UI.
Also this option has no effect if there is a IBackButtonCallback configured which handles the back presses by itself. |
void |
setBackButtonCallback(IBackButtonCallback backButtonCallback)
Defines the callback for back button presses while the Unblu UI is displayed.
If it is null, the SDK will handle all back button presses itself. |
void |
setCustomBackgroundColor(java.lang.Integer customBackgroundColor)
Sets the background color for the Unblu UI.
|
void |
setCustomCookies(java.util.Set<UnbluCookie> customCookies)
Sets the given cookies for the configured unblu base url.
|
void |
setCustomLoadingViewCreator(IUnbluCustomLoadingViewCreator customLoadingViewCreator)
Sets a custom loading view creator.
|
static void |
setLogLevel(LogLevel logLevel)
Sets the log level of the Unblu SDK.
|
void |
setNamedArea(java.lang.String namedArea)
Sets or updates the named area.
|
void |
setUiMargins(int top,
int bottom)
Sets a margins of the UI.
This can be used, if there should be a an open/close fab button or some menu at the top. The top margin starts bellow the status bar. The bottom margin starts above the navigation bar, if navigation bar is visible. |
void |
showUi(boolean show,
boolean animate,
IUnbluApiSuccessVoidCallback success,
IUnbluShowUiExceptionCallback failure)
This will show/hide the UI.
|
void |
showUi(boolean show,
IUnbluApiSuccessVoidCallback success,
IUnbluShowUiExceptionCallback failure)
This will show/hide the UI.
This will animate the show/hide of the UI. |
void |
startAudioCall(java.lang.String conversationId,
IUnbluApiSuccessVoidCallback success,
IUnbluApiStartAudioCallExceptionCallback failure)
Opens a conversation for the given conversation id and starts an audio call.
The unblu UI must have been visible at least once. |
void |
startVideoCall(java.lang.String conversationId,
IUnbluApiSuccessVoidCallback success,
IUnbluApiStartVideoCallExceptionCallback failure)
Opens a conversation for the given conversation id and starts a video call.
The unblu UI must have been visible at least once. |
public static boolean enableDebugOutput
setLogLevel(LogLevel)
.public static boolean enableCapturingPerformanceLogging
IMPORTANT: This only has effect, if enableDebugOutput
is set to true and the log level is set to LogLevel.DEBUG
via setLogLevel(LogLevel)
!
public static final long ANIMATION_TIME
protected UnbluCoreApi(T apiDelegate)
public static <D extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate> UnbluCoreApi<D> internalGetCoreInstance()
D
- classUnbluCoreApi
. Only for internal use!java.lang.IllegalStateException
- If the core api was not initialized by either using UnbluVisitorApi or UnbluAgentApipublic static void setLogLevel(LogLevel logLevel)
LogLevel.VERBOSE
as in release builds the verbose and debug logs are stripped out via proguard.logLevel
- Level which should be setgetLogLevel()
public static LogLevel getLogLevel()
setLogLevel(LogLevel)
public android.app.Application getApplication()
getApplication
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
public void configureApi(UnbluApiConfiguration configuration)
initApi(IUnbluApiSuccessfullyInitializedCallback, IUnbluApiInitializeExceptionCallback)
to be able start new conversation and use other API features.
Note:
configureApi
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
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 initApi(@Nullable IUnbluApiSuccessfullyInitializedCallback success, @Nullable IUnbluApiInitializeExceptionCallback failure)
This is an asynchronous call. Any further calls can be done inside the success callback or after the IUnbluEventApi.ApiIsInitialized
event.
Connects to the unblu server and makes the API ready for further calls.
Consecutive calls (without deinitializing in between) will be ignored, but the callbacks will also be triggered, as soon as there is a result.
initApi
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
success
- Optional callback that will be called once the API has been successfully initialized and also provides a callback if the pre loading chat ui was loaded (if preloading was enabled)failure
- Optional callback that will be called if the initialization of the API fails.public void initApi(@NonNull android.app.Activity activeActivity, @Nullable IUnbluApiSuccessfullyInitializedCallback success, @Nullable IUnbluApiInitializeExceptionCallback failure)
This is an asynchronous call. Any further calls can be done inside the success callback or after the IUnbluEventApi.ApiIsInitialized
event.
Connects to the unblu server and makes the API ready for further calls.
Consecutive calls (without deinitializing in between) will be ignored, but the callbacks will also be triggered, as soon as there is a result.
Use this method if you are NOT extending your Application class after UnbluCoreApplication
or a class which should inherit it and also if you are NOT using the UnbluApplicationHelper
initApi
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
activeActivity
- the Activity which is currently active so it can bind the UnbluUI.success
- Optional callback that will be called once the API has been successfully initialized and also provides a callback if the pre loading chat ui was loaded (if preloading was enabled)failure
- Optional callback that will be called if the initialization of the API fails.public void deinitApi(@Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluDeinitializeExceptionCallback failure)
This is an asynchronous call. Use the callbacks to check for success / failure.
Calling this method will free all resources allocated by the unblu API.
Consecutive calls (without initializing in between) will be ignored, but the callbacks will also be triggered, as soon as there is a result.
deinitApi
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
success
- Optional callback that will be called once the API has been successfully deinitialized.failure
- Optional callback that will be called if the deinitialization of the API fails.public boolean isInitialized()
isInitialized
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
public boolean isInErrorState()
isInErrorState
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
public void preloadUi(@Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluApiNotInitializedExceptionCallback failure)
configureApi(UnbluApiConfiguration)
is set to true, this call is not needed
This is an asynchronous call. Use the callbacks to check for success / failure.
preloadUi
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
success
- Optional callback that will be called once the preloading is finished.failure
- Optional callback that will be called if the api was not initialized.public void setCustomCookies(@NonNull java.util.Set<UnbluCookie> customCookies)
This can be called independent of the state of the api.
If the api was already initialized and cookies were already placed, it will overwrite cookies with the same key. Others will not be touched.
All cookies will be removed when deinitApi(IUnbluApiSuccessVoidCallback, IUnbluDeinitializeExceptionCallback)
was called.
When initApi(IUnbluApiSuccessfullyInitializedCallback, IUnbluApiInitializeExceptionCallback)
is called again the last cookies set will be used again.
Constructors for UnbluCookie:
UnbluCookie(String, String, Date)
Factory Methods:
setCustomCookies
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
customCookies
- The cookies which will be send with request to the configured base url.public void setAutoHideUiOnBack(boolean autoHideUiOnBack)
IBackButtonCallback
configured which handles the back presses by itself.setAutoHideUiOnBack
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
autoHideUiOnBack
- True to enabled hiding the UI when back button is pressed, false to disable itpublic void setBackButtonCallback(@Nullable IBackButtonCallback backButtonCallback)
setAutoHideUiOnBack(boolean)
is true,
it will hide the UI when the top level of the UI is reached.setBackButtonCallback
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
backButtonCallback
- The listener which handles the back button presspublic void isCallUiOpen(@NonNull IUnbluApiSuccessCallback<java.lang.Boolean> success, @Nullable IUnbluApiNotInitializedExceptionCallback failure)
isCallUiOpen
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
success
- Optional callback that will be called with the result if the UI is open or notfailure
- Optional callback that will be called if the api was not initializedpublic void showUi(boolean show, @Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluShowUiExceptionCallback failure)
show
- True to show the UI. False to hide it.success
- Called after the UI is shown/hidden. Triggered after the animation.failure
- Called if there is an issue showing the UIpublic void showUi(boolean show, boolean animate, @Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluShowUiExceptionCallback failure)
showUi
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
show
- True to show the UI. False to hide it.animate
- True to animation the show/hide of the UI.success
- Called after the UI is shown/hidden. Triggered after the animation.failure
- Called if there is an issue showing the UIpublic boolean isUiVisible()
isUiVisible
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
public void setUiMargins(int top, int bottom)
setUiMargins
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
top
- The amount of margin in pixel at the topbottom
- The amount of margin in pixel at the bottompublic int getUiTopMargin()
getUiTopMargin
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
public int getUiBottomMargin()
getUiBottomMargin
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
public void openConversation(@NonNull java.lang.String conversationId, @Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluApiOpenConversationExceptionCallback failure)
showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
(wait for the success callback).openConversation
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
conversationId
- The id of the conversation which should be opened.success
- Called after the conversation was openedfailure
- Called if there was an error opening the conversationpublic void startAudioCall(@NonNull java.lang.String conversationId, @Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluApiStartAudioCallExceptionCallback failure)
showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
(wait for the success callback).startAudioCall
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
conversationId
- The id of the conversation in which the audio call should be startedsuccess
- Called after the conversation was opened and the call has been startedfailure
- Called if there was an error opening the conversation and starting the callpublic void startVideoCall(@NonNull java.lang.String conversationId, @Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluApiStartVideoCallExceptionCallback failure)
showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
(wait for the success callback).startVideoCall
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
conversationId
- The id of the conversation in which the video call should be started.success
- Called after the conversation was opened and the call has been startedfailure
- Called if there was an error opening the conversation and starting the callpublic void openConversationOverview(@Nullable IUnbluApiSuccessVoidCallback success, @Nullable IUnbluApiOpenConversationOverviewExceptionCallback failure)
showUi(boolean, IUnbluApiSuccessVoidCallback, IUnbluShowUiExceptionCallback)
(wait for the success callback).openConversationOverview
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
success
- Called when the overview was openedfailure
- Called if there was an error opening the overview@Nullable public java.lang.String getOpenConversationId()
getOpenConversationId
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
java.lang.IllegalStateException
- if the API is not initialized or if the UI was never shown.public int getUnreadMessagesCount()
getUnreadMessagesCount
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
@Nullable public PersonInfo getPersonInfo()
getPersonInfo
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
java.lang.IllegalStateException
- if the API is not initializedUnsupportedCollaborationServerVersionException
- if the used collaboration server is not of version 5.x newer than 5.17 or newer than 6.3public void setCustomLoadingViewCreator(@Nullable IUnbluCustomLoadingViewCreator customLoadingViewCreator)
setCustomLoadingViewCreator
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
customLoadingViewCreator
- The loading view creator which should be used whenever a loading view is displayed@Nullable public IUnbluCustomLoadingViewCreator getCustomLoadingViewCreator()
getCustomLoadingViewCreator
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
@NonNull public static IUnbluNotificationApi getNotificationApi()
public void setApplicationContext(@NonNull android.app.Application application)
application
- The UnbluCoreApplication
or a class which should inherit it.public void setNamedArea(java.lang.String namedArea)
setNamedArea
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
namedArea
- The named area meta tag id which is configured on the agent desk.public void setCustomBackgroundColor(@ColorRes java.lang.Integer customBackgroundColor)
setCustomBackgroundColor
in class com.unblu.sdk.core.internal.InternalUnbluCoreApi<T extends com.unblu.sdk.core.internal.IUnbluCoreApiDelegate>
customBackgroundColor
- The background color resource