Skip to content

Chat

ConnectyCube Chat API is built on top of Real-time(XMPP) protocol. In order to use it you need to setup real-time connection with ConnectyCube Chat server and use it to exchange data.

By default Real-time Chat works over secure TLS connection.

val user = ConnectycubeUser().apply {
id = 21
password = "supersecurepwd"
}
// or just
val user = user {
id = 21
password = "supersecurepwd"
}
ConnectyCube.chat.login(user, {}, { ex -> Log.d(tag, "login ex= $ex") })

Use ConnectionListener to handle different connection states:

ConnectyCube.chat.addConnectionListener(object : ConnectycubeConnectionListener {
override fun onConnected() {
}
override fun onDisconnected() {
}
})

Connect to chat using custom authentication providers

Section titled “Connect to chat using custom authentication providers”

In some cases we don’t have a user’s password, for example when login via:

  • Facebook
  • Twitter
  • Firebase phone authorization
  • Custom identity authentication
  • etc.

In such cases ConnectyCube API provides possibility to use ConnectyCube session token as a password for chat connection:

val token = ConnectycubeSessionManager.getToken()
val user = ConnectycubeUser().apply {
id = 21
password = token
}

To logout from chat connection use logout method:

val isLoggedIn = ConnectyCube.chat.isLoggedIn()
if (!isLoggedIn) {
return
}
ConnectyCube.chat.logout({}, { ex -> Log.d(tag, "logout ex= $ex") })

To fully destroy chat connection use destroy method:

ConnectyCube.chat.destroy()

The SDK reconnects automatically when connection to Chat server is lost.

There is a way to disable it and then manage it manually:

//Coming soon

All chats between users are organized in dialogs. The are 4 types of dialogs:

  • 1-1 chat - a conversation between 2 users.
  • group chat - a conversation between specified list of users.
  • public chat - an open conversation. Any user from your app can subscribe to it.
  • broadcast - chat where a message is sent to all users within application at once. All the users from the application are able to join this group. Broadcast dialogs can be created only via Admin panel.

You need to create a new dialog and then use it to chat with other users. You also can obtain a list of your existing dialogs.

You need to pass ConnectycubeDialogType.PRIVATE as a type and an id of an opponent you want to create a chat with:

val dialog = ConnectycubeDialog(type = ConnectycubeDialogType.PRIVATE, occupantsIds = occupantIds)
ConnectyCube.createDialog(cubeDialog, { dialog ->
}, { error ->
})

You need to pass ConnectycubeDialogType.GROUP as a type and ids of opponents you want to create a chat with:

val dialog = ConnectycubeDialog( type = ConnectycubeDialogType.GROUP, name = "Hawaii party", occupantsIds = occupantIds)
ConnectyCube.createDialog(cubeDialog, { dialog ->
}, { error ->
})

It’s possible to create a public chat, so any user from your application can subscribe to it. You need to pass ConnectycubeDialogType.PUBLIC as a type to create a chat with:

val dialog = ConnectycubeDialog(type = ConnectycubeDialogType.PUBLIC, name = "Blockchain trends")
ConnectyCube.createDialog(cubeDialog, { dialog ->
}, { error ->
})

With public dialog ID any a user can subscribe to the public dialog via the following code:

ConnectyCube.subscribeToDialog(dialogId, { dialog ->
}, { error ->
})

After dialog subscription, this dialog will be listed in retrieve dialogs request and you also will be able to chat in it.

You also can unsubscribe if you do not want to be in this public dialog anymore:

ConnectyCube.unSubscribeFromDialog(dialogId, {
}, { error ->
})

A dialog can have up to 3 custom sub-fields to store additional information that can be linked to chat.

To start using extensions, allowed fields should be added first. Go to Admin panel > Chat > Custom Fields and provide allowed custom fields.

Dialog Extensions fields configuration example

When create a dialog, the extensions field object must contain allowed fields only. Others fields will be ignored. The values will be casted to string.

val dialog = ConnectycubeDialog(ConnectycubeDialogType.GROUP)
dialog.name = "Friday party"
dialog.occupantsIds = arrayListOf(29085, 29086, 29087)
dialog.description = "lets dance the night away"
dialog.extensions = hashMapOf("location" to "Sun bar")
ConnectyCube.createDialog(dialog, { createdDialog -> }, { error -> })

When remove custom field in Admin panel, this field will be removed in all dialogs respectively.

These parameters also can be used as a filter for retrieving dialogs.

Chat could have different permissions to managa data access. This is managed via permissions field.

At the moment, only one permission available - allow_preview - which allows to retrieve dialog’s messages for user who is not a member of dialog. This is useful when implement feature like Channels where a user can open chat and preview messages w/o joining it.

Note

To preview messages w/o joining to dialog pass preview operator in request to get messages.

It’s common to request all your conversations on every app login:

val params: HashMap<String, Any> = hashMapOf(
"limit" to 50,
"skip" to 100
)
ConnectyCube.getDialogs(params, successCallback = { resultDialogs ->
}, errorCallback = { error ->
})

It will return all your 1-1 dialogs, group dialog and also public dialogs your are subscribed to.

If you want to retrieve only conversations updated after some specific date time, you can use requestBuilder.gt("updated_at", "1455098137"); filter. This is useful if you cache conversations somehow and do not want to obtain the whole list of your conversations on every app start.

Update dialog’s name, description, photo

Section titled “Update dialog’s name, description, photo”

User can update group chat name, description, photo:

val dialogId = "5356c64ab35c12bd3b108a41"
val params = UpdateDialogParams() //class-helper to simple config search request
params.newName = "Hawaii party"
params.newPhoto = "https://new_photo_url"
params.newDescription = "New dialog description"
ConnectyCube.updateDialog(dialogId, params.getUpdateDialogParams(), successCallback = { resultDialog ->
}, errorCallback = { error ->
})

You can add/remove occupants in group and public dialogs:

val dialogId = "5356c64ab35c12bd3b108a41"
val params = UpdateDialogParams()
params.addOccupantIds = hashSetOf(378)
// params.deleteOccupantIds = hashSetOf(22)
ConnectyCube.updateDialog(dialogId, params.getUpdateDialogParams(), successCallback = { resultDialog ->
}, errorCallback = { error ->
})

Note

Only group chat owner and admins can remove other users from group chat.

Admins it’s a special role in chats. They have the same permissions as a dialog’s creator except add/remove other admins and remove dialog.

Owner of the group chat dialog can add admins:

val dialogId = "5356c64ab35c12bd3b108a41"
val params = UpdateDialogParams()
params.addAdminIds = hashSetOf(17616, 17617)
ConnectyCube.updateDialog(dialogId, params.getUpdateDialogParams(), successCallback = { resultDialog ->
}, errorCallback = { error ->
})

and remove:

val dialogId = "5356c64ab35c12bd3b108a41"
val params = UpdateDialogParams()
params.deleteAdminIds = hashSetOf(17616, 17617)
ConnectyCube.updateDialog(dialogId, params.getUpdateDialogParams(), successCallback = { resultDialog ->
}, errorCallback = { error ->
})

Pinning a message allows group owner or chat admins to easily store messages which are important, so that all users in chat have a quick access to them. The following code pins some messages to a particular group dialog:

val dialogId = "5356c64ab35c12bd3b108a41"
val params = UpdateDialogParams()
params.addPinnedMsgIds = hashSetOf("5356c64ab35c12bd3b10ba32", "5356c64ab35c12bd3b10wa65")
// params.deletePinnedMsgIds = hashSetOf("5356c64ab35c12bd3b10ba32", "5356c64ab35c12bd3b10wa65")
ConnectyCube.updateDialog(dialogId, params.getUpdateDialogParams(), successCallback = { resultDialog ->
}, errorCallback = { error ->
})

The following snippet is used to delete a conversation:

val dialogId = "5356c64ab35c12bd3b108a41"
val forceDelete = false
ConnectyCube.deleteDialog(dialogId, forceDelete, successCallback = { },
errorCallback = { })

This request will remove this conversation for current user, but other users still will be able to chat there. The forceDelete parameter is used to completely remove the dialog. Only group chat owner can remove the group conversation for all users.

You can also delete multiple conversations in a single request.

Every chat conversation stores its chat history which you can retrieve:

val dialogId = "5356c64ab35c12bd3b108a41"
val messageGetBuilder: GetMessagesParameters = GetMessagesParameters().also { it.limit = 100; it.markAsRead = false; it.sorter = RequestSorter("", "date_sent", "desc")}
ConnectyCube.getMessages(dialogId, messageGetBuilder.getRequestParameters(), successCallback = { pagedMessagesResult ->
}, errorCallback = { error ->
})

If you want to retrieve chat messages that were sent after or before specific date time only, you can use messageGetBuilder.gt("date_sent", "1455098137") or messageGetBuilder.lt("date_sent", "1455098137") filter. This is useful if you implement pagination for loading messages in your app.

Note

All retrieved chat messages will be marked as read after the request. If you decided not to mark chat messages as read, then add the following parameter to your request: messageGetBuilder.markAsRead(false);

There is IncomingMessagesManager to listen for all incoming messages from all dialogs.

ConnectyCube.chat.addMessageListener(object: ConnectycubeMessageListener {
override fun onError(message: ConnectycubeMessage, ex: Throwable) {
}
override fun onMessage(message: ConnectycubeMessage) {
}
})

!> Pay attention, messages from group & public chat dialogs will be received in this callback only after you join the dialogs.

!> Pay attention, before using dialog you need to init it for ConnectycubeChatService. Call this once you’ve got dialog - chatDialog.initForChat(ConnectycubeChatService.getInstance()).

ConnectyCube.chat.addMessageListener(object: ConnectycubeMessageListener {
override fun onError(message: ConnectycubeMessage, ex: Throwable) {
}
override fun onMessage(message: ConnectycubeMessage) {
}
})

Before you start chatting in a group/public conversation, you need to join it by calling join method:

val groupChatDialog = ...
groupChatDialog.join(object : EntityCallback<Void?> {
override fun onSuccess(result: Void?, args: Bundle?) {
}
override fun onError(exception: ResponseException) {
}
})

Then you are able to send/receive messages:

val chatMessage = ConnectycubeMessage()
chatMessage.dialogId = dialogId
chatMessage.saveToHistory = true
chatMessage.dateSent = System.currentTimeMillis() / 1000
chatMessage.markable = true
if(dialog.type == ConnectycubeDialogType.PRIVATE) chatMessage.recipientId = dialog.getRecipientId()
else chatMessage.type = when (dialog.type) {
ConnectycubeDialogType.GROUP, ConnectycubeDialogType.PUBLIC -> ConnectycubeMessageType.Groupchat
else -> ConnectycubeMessageType.Chat
}
chatMessage.body = "How are you today?"
ConnectyCube.chat.sendMessage(chatMessage)
ConnectyCube.chat.addMessageListener(object: ConnectycubeMessageListener {
override fun onError(message: ConnectycubeMessage, ex: Throwable) {
}
override fun onMessage(message: ConnectycubeMessage) {
}
})

When it’s done, you can leave the group conversation by calling leave method:

groupChatDialog.leave()

A chat message can have custom sub-fields to store additional information that can be linked to the particular chat message.

When create a message, the custom data can be attached via properties field:

val message = ConnectycubeMessage()
message.properties["field_one"] = "value_one";
message.properties["field_two"] = "value_two";

There is a ‘sent’ status to ensure that message is delivered to the server.

In order to use the feature you need to enable it:

val chatService = ConnectycubeChatService.getInstance()
chatService.setUseStreamManagement(true)
chatService.login(user)

!> Pay attention: you should enable Stream Management before logging into the chat. Stream Management is initialized only during chat login step.

The Stream Management defines an extension for active management of a stream between client and server, including features for stanza acknowledgements.

The following callback is used to track the status:

ConnectyCube.chat.addMessageSentListener(object: ConnectycubeMessageSentListener {
override fun onMessageSent(message: ConnectycubeMessage) {
}
override fun onMessageSentFailed(message: ConnectycubeMessage) {
}
})

The following callback is used to track the ‘delivered’ status:

ConnectyCube.chat.addMessageStatusListener(object: ConnectycubeMessageStatusListener {
override fun onMessageDelivered(message: ConnectycubeMessage) {
}
override fun onMessageRead(message: ConnectycubeMessage) {
}
})

The SDK sends the ‘delivered’ status automatically when the message is received by the recipient. This is controlled by chatMessage.setMarkable(true) parameter when you send a message.

If markable is false or omitted, then you can send the delivered status manually via Chat:

val chatDialog = ...
val message = ...
ConnectyCube.chat.sendDeliveredStatus(message)

and via REST

val updatedParams = UpdateMessageParameters().also { it.delivered = true }
ConnectyCube.updateMessage(messageId, dialogId, updatedParams.getRequestParameters(), {
}, { error ->
})

Send the ‘read’ status:

ConnectyCube.chat.sendReadStatus(message)

Receive the ‘read’ status callback:

ConnectyCube.chat.addMessageStatusListener(object: ConnectycubeMessageStatusListener {
override fun onMessageDelivered(message: ConnectycubeMessage) {
}
override fun onMessageRead(message: ConnectycubeMessage) {
}
})

The following ‘typing’ notifications are supported:

  • typing: The user is composing a message. The user is actively interacting with a message input interface specific to this chat session (e.g., by typing in the input area of a chat window)
  • stopped: The user had been composing but now has stopped. The user has been composing but has not interacted with the message input interface for a short period of time (e.g., 30 seconds)

Send the ‘is typing’ status:

ConnectyCube.chat.sendIsTypingStatus(chatDialog)
...
ConnectyCube.chat.sendStopTypingStatus(chatDialog)

Receive the ‘is typing’ status callback:

ConnectyCube.chat.addTypingStatusListener(object: ConnectycubeChatTypingListener {
override fun onUserIsTyping(dialogId: String?, userId: Int) {
}
override fun onUserStopTyping(dialogId: String?, userId: Int) {
}
})

The following snippet is used to edit chat message:

chatDialog.editMessageWithId("5356c64ab35c12bd3b10wa64", "Updated message body", true)

Other users will receive the ‘update’ status callback:

val messageUpdateListener = MessageUpdateListener { messageID, dialogId, newBody, isLastMessage ->
}
ConnectycubeChatService.getInstance().messageStatusesManager.addMessageUpdateListener(messageUpdateListener)

The following snippet is used to remove chat message via REST:

val messagesIds = listOf("546cc3240eda8f2dd7ee2291", "546cc3230eda8f2dd7ee2292")
ConnectyCube.deleteMessages(messagesIds, true, successCallback = { deleteResult ->
}, errorCallback = { error ->
})

This request will remove the messages from current user history only, without affecting the history of other users. The forceDelete parameter is used to completely remove messages.

The following snippet is used to remove chat message in a real time:

chatDialog.removeMessageWithId("5356c64ab35c12bd3b10wa64")

Other users will receive the ‘delete’ status callback:

val messageDeleteListener = MessageDeleteListener { messageID, dialogId ->
//actions after success deleting message
}
ConnectycubeChatService.getInstance().messageStatusesManager.addMessageDeleteListener(messageDeleteListener)

Self-destroy messages is used if you want to implement some sort of Secret Chat where messages are visible only for some limited amount of time.

It’s your responsibility to setup a timer in your app and remove messages from the client side.

Self-destroy messages are not stored in server history.

val chatMessage = ConnectycubeChatMessage().apply {
body = "Self destroy message"
destroyAfter = 10
}
chatDialog.sendMessage(chatMessage)
chatDialog.addMessageListener(object : ChatDialogMessageListener {
override fun processMessage(dialogId: String,
message: ConnectycubeChatMessage,
senderId: Int
) {
if (message.destroyAfter > 0) {
// setup a timer
}
}
override fun processError(dialogId: String,
exception: ChatException,
message: ConnectycubeChatMessage,
senderId: Int
) {
}
})

Chat attachments are supported with the cloud storage API. In order to send a chat attachment you need to upload the file to ConnectyCube cloud storage and obtain a link to the file (file UID). Then you need to include this UID into chat message and send it.

val messageAttachment = File("some_image.png")
val fileIsPublic = false
ConnectyCube.uploadFile(messageAttachment.path, fileIsPublic, successCallback = { cubeFile ->
// create a message
val chatMessage = ConnectycubeMessage()
chatMessage.saveToHistory = true
// attach a photo
val attachment = ConnectycubeAttachment("photo")
attachment.id = cubeFile.id.toString()
chatMessage.attachments?.add(attachment)
// send a chat message
// ...
}, errorCallback = { ex ->
})

The same flow is supported on the receiver’s side. When you receive a message, you need to get the file UID and then download the file from the cloud storage.

// ConnectycubeMessageListener
...
override fun onMessage(message: ConnectycubeMessage) {
message.attachments?.forEach { attachment ->
val privateAvatarUrl = getPrivateUrlForUID(attachment.url)
}
// process url
}

A contact profile can be send via chat attachments as well:

// create a message
val chatMessage = ConnectycubeMessage(saveToHistory = true)
// build a contact representation
val jc = JsonObject().apply {
add("phone", JsonPrimitive("180032323223"))
add("name", JsonPrimitive("Samuel Johnson"))
}
// attach a contact
val attachment = ConnectycubeAttachment("contact").apply {
data = jc.toString()
}
chatMessage.attachments?.add(attachment)
// send a chat message
// ...
// ConnectycubeMessageListener
override fun onMessage(message: ConnectycubeMessage) {
for (attachment in message.attachments!!) {
val data = attachment.data
val obj = JsonParser().parse(data).asJsonObject
val phone = obj.getAsJsonPrimitive("phone").asString
val name = obj.getAsJsonPrimitive("name").asString
}
}

On the receiver’s side, when you receive a message, you need to get a contact data from an attachment:

You can request total unread messages count and unread count for particular conversation:

val dialogsIds: MutableList<String> = mutableListOf("546cc3240eda8f2dd7ee2291", "546cc3230eda8f2dd7ee2292")
ConnectyCube.getUnreadMessagesCount(dialogsIds, successCallback = { result ->
Log.i(TAG, "total unread messages: ${result["546cc3240eda8f2dd7ee2291"]}")
Log.i(TAG, "total unread messages: ${result["546cc3230eda8f2dd7ee2292"]}")
}, errorCallback = { error ->
})

Global search feature was developed to simplify search of dialogs, messages and users at the same time. Similar functionality is used in most popular messengers and you can implement it in your app using Connectycube SDK. Just use request from snippet below. SearchRequestBuilder is optional parameter and it can be null if you don’t need additional configs for search request.

val searchText = "dialog name" // String or word. Should be longer than 4 symbols. Performs 'or' search.
// For an exact search, you need to wrap the search phrase in quotes.
val searchParams: GlobalSearchParams = GlobalSearchParams() //class-helper to simple config search request
searchParams.dialogIds = dialogsIds // List of dialog ids. Max cam include 10 items. Optional parameter.
searchParams.startDate = startDate // Closest date to now. Uses lte comparison. Optional parameter.
searchParams.endDate = endDate // Shouldn't differ by more than 3 months from the start_date. Uses gte comparison. Optional parameter.
searchParams.limit = 3 // Maximum number of items returned from the server in the search results. Max value - 100. Optional parameter.
ConnectyCube.searchText(searchText, searchParams.getSearchParams(), successCallback = { searchResult ->
val dialogs = searchResult.dialogs // found dialogs
val messages = searchResult.messages // found messages
val users = searchResult.users // found users
}, errorCallback = { error ->
})

When you send a chat message and the recipient/recipients is offline, then automatic push notification will be fired.

In order to receive push notifications you need to subscribe for it. Please refer to Push Notifications guide.

To configure push template which users receive - go to Dashboard Console, Chat Alerts page

Also, here is a way to avoid automatically sending push notifications to offline recipient/recipients. For it add the silent parameter with value 1 to the properties field of the instance of a ConnectycubeMessage.

val message = ConnectycubeMessage()
message.properties["silent"] = "1"

After sending such a message, the server won’t create the push notification for offline recipient/recipients.

Note

Currently push notifications are supported on mobile environment only.

A user can turn on/off push notifications for offline messages in a dialog. By default push notification are turned ON, so offline user receives push notifications for new messages in a chat.

val dialogId = "5356c64ab35c12bd3b108a41"
val enabled = false //false - to disable push notification, true - to enable
ConnectyCube.updateDialogNotificationsSettings(dialogId, enabled, { result ->
}, { error ->
})

Check a status of notifications setting - either it is ON or OFF for a particular chat.

val dialogId = "5356c64ab35c12bd3b108a41"
ConnectyCube.getDialogNotificationsSettings(dialogId, { enabled ->
}, { error ->
})

When you send a chat message and the recipient/recipients is offline, then automatic push notification will be fired.

Sometimes a client app can be in a background mode, but still online. In this case it’s useful to let server know that a user wants to receive push notifications while still is connected to chat.

For this particular case we have 2 handy methods: ‘enterInactiveState’ and ‘enterActiveState’:

ConnectycubeChatService.getInstance().enterInactiveState();
ConnectycubeChatService.getInstance().enterActiveState();

The common use case for these APIs is to call ‘enterInactiveState’ when an app goes to background mode and to call ‘enterActiveState’ when an app goes to foreground mode.

There is a way to get an info when a user was active last time, in seconds.

This is a modern approach for messengers apps, e.g. to display this info on a Contacts screen or on a User Profile screen.

val userId = 12345
val seconds = ConnectycubeChatService.getInstance().getLastUserActivity(userId)
// seconds - the difference in seconds from current time to last user activity in the chat or 0 if user is online.

There is a way to send system messages to other users about some events. System messages work on a separate channel and are not mixed with regular chat messages:

System messages are not stored on a server. It means messages will be delivered only to online users.

ConnectyCube.chat.addSystemMessageListener(object : ConnectycubeSystemMessageListener {
override fun onMessage(message: ConnectycubeMessage) {
}
override fun onError(message: ConnectycubeMessage, ex: Throwable) {
}
})
ConnectyCube.chat.sendSystemMessage(message {
recipientId = 58672
properties["param1"] = "value1"
properties["param2"] = "value2"
body = "some text"
})

The moderation capabilities help maintain a safe and respectful chat environment. We have options that allow users to report inappropriate content and manage their personal block lists, giving them more control over their experience.

For user reporting to work, it requires the following:

  1. Go to ConnectyCube Daashboard
  2. select your Application
  3. Navigate to Custom module via left sidebar
  4. Create new table called UserReports with the following fields:
  • reportedUserId - integer
  • reason - string
Chat widget: report table in ConnectyCube dashboard

Once the table is created, you can create a report with the following code snippet and then see all the reports in Dashboard:

val customObject: ConnectycubeCustomObject = ConnectycubeCustomObject("UserReports")
customObject.fields = hashMapOf (
"reportedUserId" to 45,
"reason" to "User is spamming with bad words",
)
ConnectyCube.createCustomObject(customObject, { createdObject ->
}, { ex -> })

For message reporting to work, the same approach to user reporting above could be used.

You need to create new table called MessageReports with the following fields:

  • reportedMessageId - integer
  • reason - string

Once the table is created, you can create a report with the following code snippet and then see all the reports in Dashboard:

val customObject: ConnectycubeCustomObject = ConnectycubeCustomObject("MessageReports")
customObject.fields = hashMapOf (
"reportedMessageId" to "58e6a9c8a1834a3ea6001f15",
"reason" to "The message contains phishing links",
)
ConnectyCube.createCustomObject(customObject, { createdObject ->
}, { ex -> })

Block list (aka Privacy list) allows enabling or disabling communication with other users. You can create, modify, or delete privacy lists, define a default list.

The user can have multiple privacy lists, but only one can be active.

A privacy list must have at least one element in order to be created. If no elements specified, then the list with given name will be deleted.

val list = ConnectycubePrivacyList().apply {
name = "myList"
}
val items = ArrayList<ConnectycubePrivacyListItem>()
val item1 = ConnectycubePrivacyListItem().apply {
isAllow = false
type = ConnectycubePrivacyListItem.Type.USER_ID
valueForType = 3678.toString()
isMutualBlock = true
}
items.add(item1)
list.items = items
val privacyListsManager = chatService.privacyListsManager
privacyListsManager.createPrivacyList(list)

The ConnectycubePrivacyListItem class takes 4 arguments:

  • type - use USER_ID to block a user in 1-1 chat or GROUP_USER_ID to block in a group chat.
  • valueForType - ID of a user to apply an action
  • allow - can be true/false.
  • mutualBlock - can be true/false - to block user’s message in both directions or not.

In order to be used the privacy list should be not only set, but also activated(set as default).

In order to activate rules from a privacy list you should set it as default:

privacyListsManager.applyPrivacyList("myList")

There are some rules you should follow to update a privacy list:

  • Include all of the desired items (not a “delta”).
  • If you want to update or set new privacy list instead of current one, you should decline current default list first.
// Deactivate active list
privacyListsManager.declinePrivacyList()
// Create new list
// ...
// Activate again active list
privacyListsManager.applyPrivacyList("myList")

To get a list of all your privacy lists use the following request:

val privacyListsManager = ConnectycubeChatService.getInstance().privacyListsManager
val lists = privacyListsManager.privacyLists

To get the privacy list by name you should use the following method:

var list = privacyListsManager.getPrivacyList("myList")

Note: Before deleting privacy list you should decline it.

privacyListsManager.declinePrivacyList()
privacyListsManager.deletePrivacyList("myList")

Blocked user attempts to communicate with user

Section titled “Blocked user attempts to communicate with user”

Blocked users will be receiving an error when trying to chat with a user in a 1-1 chat and will be receiving nothing in a group chat:

val chatMessage = ConnectycubeChatMessage().apply {
body = "How is going on?"
}
val chatDialog = ...
chatDialog.sendMessage(chatMessage)
...
chatDialog.addMessageListener(object : ChatDialogMessageListener {
override fun processMessage(dialogId: String,
message: ConnectycubeChatMessage,
senderId: Int
) {}
override fun processError(dialogId: String,
exception: ChatException,
message: ConnectycubeChatMessage,
senderId: Int
) {
Log.e(TAG, "processError: " + exception.localizedMessage)
}
})
Log output:
processError: Service not available.