public class StringeeClient
extends Object
Represents a Stringee client.
The first step in using Stringee Android SDK is to initialize a StringeeClient
instance by calling the StringeeClient(Context context) constructor. Then connects to Stringee server by calling
connect, pass in the access token.
For test purposes, you can generate the test token in [Dashboard -> Tools
-> Generate Access token](https://developer.stringee.com/project/tool).
Nested classes | |
---|---|
public interface StringeeConnectionListener
|
Monitors when the client connects or disconnects from Stringee server. |
public interface ChangeEventListener
|
Monitors when the conversation and message state. |
public interface UserTypingEventListener
|
Monitors when the send typing event. |
public interface LiveChatEventListener
|
Monitors when the live chat event. |
Public Constructors | |
---|---|
StringeeClient(Context context)
Construct a new StringeeClient with a context |
Public methods | |
---|---|
void |
connect(String token)
Connects to Stringee server, using provided access token. |
void |
disconnect()
Disconnects from Stringee server. |
int |
getProjectId()
Get project id. |
String |
getUserId()
Get user id. |
boolean |
isConnected()
Checks whether the client is connected to Stringee server. |
void |
registerPushToken(String token, StatusListener listener)
Registers the registration token for push notification to Stringee server. |
void |
sendCustomMessage(String toUser, JSONObject msg, StatusListener
listener)
Send a custom message to a user. |
void |
setConnectionListener(StringeeConnectionListener
connectionListener)
Sets a StringeeConnectionListener object to monitor when the client connects and disconnects from Stringee server. |
void |
unregisterPushToken(String token, StatusListener listener)
Removes the registration token for push notification from Stringee server. |
void |
createConversation(List<User>participants,
ConversationOptions options, CallbackListener<Conversation>listener)
Create conversation. |
void |
getLocalConversations(String clientId, CallbackListener<List<Conversation>>
listener)
Get conversations saved in your local database. |
void |
getLastConversations(int count, CallbackListener<List<Conversation>>
listener)
Get lastest conversations from Stringee server. |
void |
getLastUnreadConversations(int count, CallbackListener<List<Conversation>>
listener)
Get lastest unread conversations from Stringee server. |
void |
getConversationsAfter(long updateAt, int count,
CallbackListener<List<Conversation>> listener)
Get conversations after updateAt from Stringee server. |
void |
getUnreadConversationsAfter(long updateAt, int count,
CallbackListener<List<Conversation>> listener)
Get unread conversations after updateAt from Stringee server. |
void |
getConversationsBefore(long updateAt, int count,
CallbackListener<List<Conversation>> listener)
Get conversations before updateAt from Stringee server. |
void |
getUnreadConversationsBefore(long updateAt, int count,
CallbackListener<List<Conversation>> listener)
Get unread conversations before updateAt from Stringee server. |
void |
clearDb()
Clear local database. |
void |
getConversation(String convId, CallbackListener<Conversation>
listener)
Get conversation from local database. |
void |
getConversationFromServer(String convId,
CallbackListener<Conversation> listener)
Get conversation from Stringee server. |
User |
getUser(String userId)
Get a user by user id. |
void |
setChangeEventListener(ChangeEventListener
changeEventListener)
Sets a ChangeEventListener object to monitor Conversation, Message state change. |
void |
deleteMessages(String convId, JSONArray messageIds, StatusListener
listener)
Delete messages. |
void |
getChatRequests(CallbackListener<List<ChatRequest>>
listener)
Get all pending requests of live chat. |
void |
blockUser(String userId, StatusListener listener)
Block user in chat. |
void |
updateAttachment(Message message)
Update attachment url in local database. |
void |
getTotalUnread(CallbackListener<Integer> listener)
Get total number of unread conversations. |
void |
getConversationByUserId(String id, CallbackListener<Conversation>
listener)
Get chat 1-1 by user id. |
void |
getChatProfile(String key, CallbackListener<ChatProfile>
listener)
Get portal's chat profile. |
void |
getLiveChatToken(String key, String name, String email,
CallbackListener<String> listener)
Get access token for live chat. |
void |
createLiveChat(String queueId, CallbackListener<Conversation>
listener)
Create a live chat conversation. |
void |
createLiveChatTicket(String key, String name, String email,
String note, StatusListener listener)
Create ticket if not in business hour. |
void |
updateUser(String name, String email, String avatar, StatusListener
listener)
Update user info. |
void |
revokeMessages(String convId, JSONArray msgIds, boolean deleted,
StatusListener listener)
Revoke messages. |
void |
getLiveChat(String clientId, boolean ended, boolean deleted,
CallbackListener<List<Conversation>> listener)
Get local serving live chat. |
void |
setHost(List<SocketAddress> addresses)
Set host. |
void |
setBaseAPIUrl(String url)
Set API url. |
void |
setUserTypingEventListener(UserTypingEventListener userTypingEventListener)
Sets a UserTypingEventListener object to monitor when the user send typing event. |
void |
setLiveChatEventListener(LiveChatEventListener liveChatEventListener)
Sets a LiveChatEventListener object to monitor Live chat event. |
StringeeClient(Context context)
Construct a new StringeeClient with a context.
Parameters | |
---|---|
context |
The Android application context associated with this process. |
void connect(String token)
Connects to Stringee server, using provided access token.
Parameters | |
---|---|
token |
The access token generated by your server. |
void disconnect()
Disconnects from Stringee server.
int getProjectId()
Get project id.
String getUserId()
Get user id.
boolean isConnected()
Checks whether the client is connected to Stringee server.
void registerPushToken(String token, StatusListener listener)
Registers the registration token for push notification to Stringee server.
Parameters | |
---|---|
token |
The registration token |
listener |
The StatusListener instance. |
void sendCustomMessage(String toUser, JSONObject msg, StatusListener listener)
Send a custom message to a user.
Parameters | |
---|---|
toUser |
User id to send a custom message to. |
msg |
Message to send. |
listener |
A StatusListener instance. |
void setConnectionListener(StringeeConnectionListener connectionListener)
Sets a StringeeConnectionListener object to monitor when the client connects and disconnects from Stringee server.
Parameters | |
---|---|
connectionListener |
The StringeeConnectionListener instance. |
void unregisterPushToken(String token, StatusListener listener)
Removes the registration token for push notification from Stringee server.
Parameters | |
---|---|
token |
The registration token |
listener |
The StatusListener instance. |
void createConversation(List<User> participants, ConversationOptions options, CallbackListener<Conversation>
listener)
Create conversation.
Parameters | |
---|---|
participants |
List participants will in conversation |
options |
The ConversationOptions instance. |
listener |
The CallbackListener instance. |
void getLocalConversations(String clientId,
CallbackListener<List<Conversation>>listener)
Get conversations saved in your local database.
Parameters | |
---|---|
clientId |
The client id |
listener |
The CallbackListener instance. |
void getLastConversations(int count, CallbackListener<List<Conversation>>listener)
Get lastest conversations from Stringee server.
Parameters | |
---|---|
count |
The count of conversations |
listener |
The CallbackListener instance. |
void getLastUnreadConversations(int count,
CallbackListener<List<Conversation>>listener)
Get lastest unread conversations from Stringee server.
Parameters | |
---|---|
count |
The count of conversations |
listener |
The CallbackListener instance. |
void getConversationsAfter(long updateAt, int count, CallbackListener<List<Conversation>>
listener)
Get conversations after updateAt from Stringee server.
Parameters | |
---|---|
updateAt |
The time in millisecond |
count |
The count of conversations |
listener |
The CallbackListener instance. |
void getUnreadConversationsAfter(long updateAt, int count, CallbackListener<List<Conversation>>
listener)
Get unread conversations after updateAt from Stringee server.
Parameters | |
---|---|
updateAt |
The time in millisecond |
count |
The count of conversations |
listener |
The CallbackListener instance. |
void getConversationsBefore(long updateAt, int count, CallbackListener<List<Conversation>>
listener)
Get conversations before updateAt from Stringee server.
Parameters | |
---|---|
updateAt |
The time in millisecond |
count |
The count of conversations |
listener |
The CallbackListener instance. |
void getUnreadConversationsBefore(long updateAt, int count, CallbackListener<List<Conversation>>
listener)
Get unread conversations before updateAt from Stringee server.
Parameters | |
---|---|
updateAt |
The time in millisecond |
count |
The count of conversations |
listener |
The CallbackListener instance. |
void clearDb()
Clear local database.
void getConversation(String convId, CallbackListener<Conversation> listener)
Get conversation from local database.
Parameters | |
---|---|
convId |
The Conversation id |
listener |
The CallbackListener instance. |
void getConversationFromServer(String convId, CallbackListener<Conversation> listener)
Get conversation from Stringee server.
Parameters | |
---|---|
convId |
The Conversation id |
listener |
The CallbackListener instance. |
User getUser(String userId)
Get a user by user id.
Parameters | |
---|---|
userId |
The User id |
void setChangeEventListener(ChangeEventListener changeEventListener)
Sets a ChangeEventListener object to monitor Conversation, Message state change.
Parameters | |
---|---|
changeEventListener |
The ChangeEventListener instance. |
void deleteMessages(String convId, JSONArray messageIds, StatusListener listener)
Delete messages.
Parameters | |
---|---|
convId |
The Conversation id |
messageIds |
List messages's ids |
listener |
The StatusListener instance. |
void getChatRequests(CallbackListener<List<ChatRequest>> listener)
Get all pending requests of live chat.
Parameters | |
---|---|
clientId |
The Client id |
listener |
The CallbackListener instance. |
void blockUser(String userId, StatusListener listener)
Block user in chat.
Parameters | |
---|---|
userId |
The User id |
listener |
The StatusListener instance. |
void updateAttachment(Message message)
Update attachment url in local database.
Parameters | |
---|---|
Message |
The Message instance. |
void getTotalUnread(String clientId, CallbackListener<Integer> listener)
Get total number of unread conversations.
Parameters | |
---|---|
clientId |
The Client id |
listener |
The CallbackListener instance. |
void getConversationByUserId(String id, CallbackListener<Conversation> listener)
Get chat 1-1 by user id.
Parameters | |
---|---|
id |
The User id |
listener |
The CallbackListener instance. |
void getChatProfile(String key, CallbackListener<ChatProfile> listener)
Get portal's chat profile.
Parameters | |
---|---|
key |
The widget key |
listener |
The CallbackListener instance. |
void getLiveChatToken(String key, String name, String email, CallbackListener<String>
listener)
Get access token for live chat.
Parameters | |
---|---|
key |
The widget key |
name |
The customer name |
email |
The customer email |
listener |
The CallbackListener instance. |
void createLiveChat(String queueId, CallbackListener<Conversation> listener)
Create a live chat conversation.
Parameters | |
---|---|
queueId |
The queue's id which you will route the live chat conversation to |
listener |
The CallbackListener instance. |
void createLiveChatTicket(String key, String name, String email, String note, StatusListener
listener)
Create ticket if not in business hour.
Parameters | |
---|---|
key |
The widget key |
name |
The customer name |
email |
The customer email |
note |
The ticket description |
listener |
The StatusListener instance. |
void updateUser(String name, String email, String avatar, StatusListener listener)
Get all pending requests of live chat.
Parameters | |
---|---|
name |
The customer name |
email |
The customer email |
avatar |
The customer avatar url |
listener |
The StatusListener instance. |
void revokeMessages(String convId, JSONArray msgIds, boolean deleted, StatusListener listener)
Get all pending requests of live chat.
Parameters | |
---|---|
convId |
The Conversation id |
msgIds |
List id of messages |
deleted |
Is message deleted |
listener |
The StatusListener instance. |
void getLiveChat(String clientId, boolean ended, boolean deleted, CallbackListener<List<Conversation>>
listener)
Get local serving live chat.
Parameters | |
---|---|
clientId |
The Client id |
ended |
Is live chat ended |
deleted |
Is live chat deleted |
listener |
The CallbackListener instance. |
void setHost(List<SocketAddress> addresses)
Set host.
Parameters | |
---|---|
addresses |
List Socket addresses |
void setBaseAPIUrl(String url)
Set API url.
Parameters | |
---|---|
url |
The API url. |
void setUserTypingEventListener(UserTypingEventListener userTypingEventListener)
Sets a UserTypingEventListener object to monitor when the user send typing event.
Parameters | |
---|---|
userTypingEventListener |
The UserTypingEventListener instance. |
void setLiveChatEventListener(LiveChatEventListener liveChatEventListener)
Sets a LiveChatEventListener object to monitor live chat event.
Parameters | |
---|---|
liveChatEventListener |
The LiveChatEventListener instance. |