To use the DolphinLiveChat SDK library, please follow these steps :
You need to import our library into yourr project
You can assamble dolphin lib and get arr file. (In android studio: Gradle-> Expand dolphinlib-> build -> double click assemble)
After the build is complete, you will get the aar location
Move the file to the “libs” folder of the client-app
You need to add some dependencies to your milk app .gradle file. Then, sync to compile 3Dolphins SDK. For example, include DolphinLiveChat into your project by placing it in the libs/ folder for example, as a Gradle compile dependency.
Represents the identify of the user initiating the chat
username
Represents the name of the user
email
Represents the user's email
phoneNumber
Represents the user's phone number
uid
Used to determine whether this user session will create a new ticket or not
If you have additional fields to be sent to the sever, you can include the in customVariables. Below is an example of customeVariableas (JsonArray)
JSONArray customVariables = new JSONArray();
JSONObject field = new JSONObject();
field.put("name", "Doni");
customVariables.put(field);
dolphinProfile.customVariableJsonArray = customVariables
After successfully initializing the Dolphin connector, you can authenticate to the server using :
dolphinLiveChatConnector.connect(dolphinProfile)
Event Handler
The DolphiChat SDK uses EventBus to broadcast events throughout the application. You need register the object that will receive events from EventsBus. You can call it as follows :
EventBus.getDefault().register(this);
You can put this code in onResume(), onCreate() or onStart() method
Once you no longer need to capture the event, you should unregister the receiver by calling this method
EventBus.getDefault().unregister(this);
You can put this code in onDestroy() method
Receive Message
To receive message, do the following :
@Subscribe
public void onReceiveMessage(ChatEvent chatEvent) {
when (chatEvent.status) {
ChatEvent.Status.INCOMING -> {
// do something
// chatEvent.chat get chat data
// chatEvent.type get chat type
}
ChatEvent.Status.MESSAGE_READ -> {
// do something
// chatEvent.chat get chat data
// chatEvent.type get chat type
}
ChatEvent.Status.MESSAGE_SENT -> {
// do something
// chatEvent.chat get chat data
// chatEvent.type get chat type
}
ChatEvent.Status.MESSAGE_SEND_FAILED -> {
// do something
// chatEvent.status get chat status
}
ChatEvent.Status.AGENT_TYPING -> {
// do something
// chatEvent.chat get chat data
// chatEvent.type get chat type
}
else -> return
}