Learn how to create and manage dialogs.
private
and ID of the opponent you want to create a chat with.
group
and IDs of opponents you want to create a chat with.
public
.
join()
method. If you’ve successfully joined the dialog, you can send/receive messages in real-time. See this section to learn how to send/receive messages.
join()
method is used with regard to the dialog type.
Capabilities | Public | Group | Private |
---|---|---|---|
Join | ✓ | ✓ | ✗ |
occupantIDs
array, in the dialog model.Your user ID is added to the occupantIDs
array if you create a dialog or you are added to the dialog by the other user. See this section to learn how to add occupants to the group dialog.onJoinOccupant
event, use the code snippet below. As a result, you will be notified by the SDK about the onJoinOccupant()
event whenever the occupant has joined the current group dialog.
leave()
method. If the dialog is left, you can’t send/receive messages. To be able to receive/send messages, you need to join it.
leave()
method is used with regard to the dialog type.
Capabilities | Public | Group | Private |
---|---|---|---|
Leave | ✓ | ✓ | ✗ |
occupantIDs
array, in the dialog model. As a result, the dialog will still be present in the list of dialogs and you will still have access to the chat history.To remove yourself from the group dialog, use the update()
method. See this section to learn how to remove occupants from the group dialog.onLeaveOccupant
event, use the code snippet below. As a result, you will be notified by the SDK about the onLeaveOccupant()
event whenever the occupant has left the current group dialog.
chatDialog
dialog. Call the requestOnlineUsers()
method to get the list of online users who are joined to the dialog. As a result, a completion block with an array of user IDs or failure error is called.
requestOnlineUsers()
method is used with regard to the dialog type.
Capabilities | Public | Group | Private |
---|---|---|---|
Retrieve online users | ✗ | ✓ | ✗ |
last_message_date_sent
in descending order, and limited to 10 dialogs per page.
Argument | Required | Description |
---|---|---|
responsePage | no | If you want to get a paginated list of users from the server, you can set the following fields of the responsePage:- skip allows to skip N records in search results. Default (if not specified): 0.- limit allows limit search results to N records. Default value: 100. |
extendedRequest | yes | A dictionary that stores keys and values of the String type. The keys are formed as parameters of the List Dialogs request. |
extendedRequest
dictionary.
Search operators | Applicable to types | Applicable to fields | Description |
---|---|---|---|
lt | number, string, date | last_message_date_sent, created_at, updated_at | Less Than operator. |
lte | number, string, date | last_message_date_sent, created_at, updated_at | Less Than or Equal to operator. |
gt | number, string, date | last_message_date_sent, created_at, updated_at | Greater Than operator. |
gte | number, string, date | last_message_date_sent, created_at, updated_at | Greater Than or Equal to operator. |
ne | number, string, date | _id, name, last_message_date_sent | Not Equal to operator. |
in | number, string, date | type, last_message_date_sent, name | IN array operator. |
nin | number, string, date | last_message_date_sent | IN array operator. |
all | number, string, date | last_message_date_sent | ALL are contained in array. |
ctn | number, string, date | name | All records that contain a particular substring. |
last_message_date_sent
field.
Sort operator | Applicable to types | Applicable to fields | Description |
---|---|---|---|
sort_asc | All types | id, created_at, name, last_message_date_sent | Search results will be sorted in ascending order by the specified field. |
sort_desc | All types | id, created_at, name, last_message_date_sent | Search results will be sorted in descending order by the specified field. |
Capabilities | Public dialog | Group dialog | Private dialog |
---|---|---|---|
Update a dialog name | Owner | Owner | ✗ |
Update a photo | Owner | Owner | ✗ |
Update custom parameters | Owner,Occupant | Owner,Occupant | Owner,Occupant |
pushOccupantsIDs
field to add occupants to the group dialog. As a result, the user ID will be added to the occupantIDs
array.
Parameters | Required | Description |
---|---|---|
chatDialog | Yes | Specifies chatDialog fields that should be set. |
Capabilities | Public dialog | Group dialog | Private dialog |
---|---|---|---|
Add other users | ✗ | Owner,Occupant | ✗ |
pullOccupantsIDs
field to remove occupants from the group dialog. As a result, the user ID will be removed from the occupantIDs
array.
Parameters | Required | Description |
---|---|---|
chatDialog | Yes | Specifies chatDialog fields that should be set. |
Capabilities | Public dialog | Group dialog | Private dialog |
---|---|---|---|
Remove other users | ✗ | Owner | ✗ |
Remove yourself | ✗ | Owner,Occupant | ✗ |
forAllUsers
parameter as true
to completely remove the dialog for all users. You can also delete multiple dialogs in a single request.
Let’s see what capabilities a particular user role has with regard to the dialog type.
Capabilities | Public | Group | Private |
---|---|---|---|
Delete a dialog for all usersusing the forAllUsersparameter | Owner | Owner | Owner |
Delete a dialog for a current user | Owner | Owner,Occupant | Owner,Occupant |
countOfDialogs(withExtendedRequest:)
method. The request below will return a count of dialogs updated over the last month.
Argument | Required | Description |
---|---|---|
extendedRequest | yes | A dictionary that stores keys and values of the String type. The keys are formed as patameters of the List Dialogs request. |
totalUnreadMessageCountForDialogs()
method . It returns the total count of unread messages for all dialogs of the user in totalUnreadCount
. It also returns unread messages count for dialogs with IDs in dialogsDictionary
if any dialogIDs
are specified.
Argument | Required | Description |
---|---|---|
dialogIDs | yes | IDs of dialogs.- If dialogIDs are not specified, the total number of unread messages for all dialogs of the user will be returned.- If dialogIDs are specified, the number of unread messages for each specified dialog will be returned. Also, the total number of unread messages for all dialogs of the user will be returned. |