Android SDK
# Android Integration Description
Sobot SDK provides the capability of APP access to reception agents. Simply embedded, it can monitor and process customer inquiries in real time. Online customer reception can also be achieved on the mobile phone without downloading the Sobot APP.
Live chat SDK has the following features:
- Online inquiry: Agents can send or receive images, videos, emojis and other messages in real-time chats with customers.
- User follow, smart reply, quick reply, chat summary, user evaluation invitation.
- Highly customized UI.
Related limits and notes:
Android SDK supports Android above 4.2(API 17) and supports both portrait mode and landscape mode.
Android Studio should be upgraded to versions above 3.0.
Android SDK requires storage and photo permissions; otherwise, some functions are not available.
# File Introduction
# ● Schematic Diagram of Integration Process
# ● File Description
SDK files include SDK source package (onlinesdk) , Demo source code (Android_Online_SDK) , Demo installation package (sobot_online_sdk_demo.apk) , and Doc related documentation.
File | Description |
---|---|
SobotOnlineService | The file provides an access function |
# Integration Method
# ● Dependency Integration
// Basic
api 'com.sobot.chat:onlinesdk:1.0.2.1'
// AndroidX
api 'com.sobot.chat:onlinesdk_x:1.0.2.1'
2
3
4
5
In build.gradle:
dependencies {
api 'com.sobot.chat:onlinesdk:1.0.2.1'
implementation ' com.squareup.okhttp3 :okhttp: 4.4.0 '
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
// Three common image loader libraries are supported, and dependencies should be added to one of them
// implementation ' com.nostra13.universalimageloader :universal-image-loader: 1.9.5 '
// implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.bumptech.glide:glide:4.9.0'
// When using glide with above 4.9.0 version, you need to add additional dependencies
implementation 'com.sobot.chat:sobotsupport-glidev4:2.1'
}
2
3
4
5
6
7
8
9
10
11
12
[Note] Since the APIs of Glide v3 and v4 are completely different, we have adopted a special integration method to make SDK support any version of Glide. Under normal conditions, you can add Glide dependency and sobotsdk dependency directly when using Glide, so that the SDK can be used normally. In case of any error, you can upgrade Glide to versions above 4.4.0.
When using Glide with version above 4.9.0, you can add the following dependency:
implementation 'com.sobot.chat:sobotsupport-glidev4:2.1'
# ● Import Integration
Download Link:
Basic
Android_OnlineSDK_1.0.2 (opens new window)
AndroidX
Android_OnlineSDK_X_1.0.2 (opens new window)
Import Module:
Unzip the downloaded Sobot Android_OnlineSDK_XXX.zip file, copy onlinesdk file to your project, then Build --> Clean Project, and add project dependencies in build.gradle.
After the above steps, content in build.gradle will be displayed as follows:
dependencies {
// sdk live chat
implementation project(": onlinesdk")
implementation ' com.squareup.okhttp3 :okhttp: 4.4.0 '
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
// Three common image loader libraries are supported, and dependencies should be added to one of them
// implementation ' com.nostra13.universalimageloader :universal-image-loader: 1.9.5 '
// implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.bumptech.glide:glide:4.9.0'
// When using glide with above 4.9.0 version, you need to add additional dependencies
implementation 'com.sobot.chat:sobotsupport-glidev4:2.1'
}
2
3
4
5
6
7
8
9
10
11
12
13
[Note] Since the APIs of Glide v3 and v4 are completely different, we have adopted a special integration method to make SDK support any version of Glide. Under normal conditions, you can add Glide dependency and sobotsdk dependency directly when using Glide, so that the SDK can be used normally. In case of any error, you can upgrade Glide to versions above 4.4.0.
When using Glide with version above 4.9.0, you can add the following dependency:
implementation 'com.sobot.chat:sobotsupport-glidev4:2.1'
# Function Description
# ● Initialization and Domain Name Settings
Domain name description:
- If it's localized deployment, please use your deployed server domain name.
/**
* Initialization method, which shall be called before initiation method
*
* @param host can be null. The default param is Alibaba Cloud server. You can set your own domain name if you need
*/
SobotOnlineService.initWithHost(Application application, String host);
2
3
4
5
6
# ● Resource Deployment
You can add the namesake color to colors.xml in the customer app to cover the color style in the Sobot SDK; replace the images in the Sobot SDK interface by placing a namesake image resource at the same location in the main project; replace the text in the Sobot SDK interface by placing a namesake text resource at the same location in the main project.
The following are common color configurations. More color and image resources can be found in the Download Source Package in the manual integration module.
<!--Live chat Theme color Green by default -->
<color name="sobot_online_color">#0DAEAF</color>
<!--Live chat General header Background color-->
<color name="sobot_online_base_header_bg_color">#FFFFFF</color>
<!-- Status bar color-->
<color name="sobot_app_status_bar_color">@color/sobot_online_base_header_bg_color</color>
<!--Live chat Chat homepage-->
<!-- Status bar color in chat homepage-->
<color name="sobot_chat_status_bar_color">#F6F8FC</color>
<!-- File message bubble color -->
<color name="sobot_chat_file_bgColor">@color/sobot_online_color</color>
<!-- Default color of the left background of message bubble -->
<color name="sobot_chat_left_bgColor">@color/sobot_online_white_color</color>
<!-- Default color of the right background of message bubble -->
<color name="sobot_chat_right_bgColor">@color/sobot_online_color</color>
<!--Text message bubble Left-side text Color -->
<color name="sobot_left_msg_text_color">@color/sobot_online_common_gray1</color>
<!--Text message bubble Right-side text Color -->
<color name="sobot_right_msg_text_color">@color/sobot_online_white_color</color>
<!-- Hyperlink color Left -->
<color name="sobot_color_link">@color/sobot_online_blue_color</color>
<!-- Hyperlink color Right -->
<color name="sobot_color_rlink">@color/sobot_online_yellow_color</color>
<!-- Background color of chat interface prompt-->
<color name="sobot_chat_remind_bg">#59FFFFFF</color>
<!-- Font color of chat interface prompt-->
<color name="sobot_chat_remind_text_color">@color/sobot_online_common_gray3</color>
<!-- Hyperlink text color of chat interface prompt-->
<color name="sobot_chat_remind_link_color">@color/sobot_online_blue_color</color>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# ● Initiate Page
[Note: Contact the Sobot after-sales service personnel for appid and appkey. If you access with token, please refer to API File to get token (opens new window)
Method 1: Initiate with appid and appkey
/**
* Initiate agent authentication page
*
* @param context
* @param appid Company appid
* @param appkey Merchant appkey
* @param account Agent account (email)
* @param loginStatus Login status 0: occupied, 1: online, -1: default
*/
SobotOnlineService.startAuthWithAcount(Context context, String appid, String appkey, String account, int loginStatus);
2
3
4
5
6
7
8
9
10
Method 2: Initiate with token
/**
* Initiate agent authentication page by setting token
*
* @param context
* @param account Agent account (email)
* @param loginToken Agent login token
* @param loginStatus 1: online, 2: occupied, -1: to be set by agent, 0: offline, directly return
*/
public static void startAuthWithToken(Context context, String account, String loginToken, int loginStatus) {
2
3
4
5
6
7
8
9
# ● API Description
# 1. Log in
/**
* Agent login only, not executing page logic
*
* @param account Agent account (email)
* @param loginStatus Login status 0: occupied, 1: online, -1: default
*/
SobotOnlineService.doLoginWithAccount( Context context, final String account, int loginStatus);
2
3
4
5
6
7
# 2. Log out
SobotOnlineService.outAdmin(Context context;
# 3. Get unread messages
int unReadNum=SobotOnlineService.getUnReadNumber(Context context);
# 4. Register the broadcast receiver and obtain new messages
After registering the broadcast receiver, when the message channel is connected, the new messages can be obtained.
Register the broadcast receiver:
/**
* action:SobotSocketConstant.BROADCAST_SOBOT_NEW_MSG
*/
IntentFilter filter = new IntentFilter();
filter.addAction(SobotSocketConstant.BROADCAST_SOBOT_NEW_MSG);
registerReceiver(receiver, filter);
2
3
4
5
6
Receive new messages and unread messages:
Receive messages with onReceive() method of BroadcastReceiver.
// Set the new messages and unread messages received by the broadcast receiver
class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (SobotSocketConstant.BROADCAST_SOBOT_NEW_MSG.equals(intent.getAction())) {
// New message content
String content = intent.getStringExtra("msgContent");
// Full content json
String contentJson = intent.getStringExtra("msgContentJson");
SobotLogUtils.i( " new message:" + content + " content:" + contentJson);
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
# 5. Set whether to enable message reminder
/**
* Set whether to enable message reminder Not enable by default
*
* @param context
* @param flag true: ON; false: OFF
* @param smallIcon Small icon ID Set the small image in the notification bar
*/
SobotOnlineService.setNotificationFlag(Context context, false, R.drawable.sobot_logo_small_icon);
2
3
4
5
6
7
8
# Source Code and Demo
Download the Demo source code (opens new window);
Download the installation package (opens new window);
# Description of Sobot SDK's Collection and Use of Personal Information
Description of Sobot SDK's Collection and Use of Personal Information (opens new window)