QuickBlox Documentation

QuickBlox provides powerful Chat API and SDK to add real-time messaging and video calls to your web and mobile apps. Learn how to integrate QuickBlox across multiple platforms.

Advanced

Learn how to manage message statuses, attachments, contact list, offline messaging, and privacy list.

Message statuses

Every message has statuses as sent, delivered and read. Thus, in the message model you can find IDs of users who have read the message (status read) or who have received the message but it still unread (status delivered). There is no field for a sent status in the message model. We send a message to the server and if no error is returned, then it is considered as sent (by default).

Sent status

If you want to definitely know that your message has been delivered to the server you should enable stream management before connecting to Chat. See this section to learn how to enable stream management.

Then, we send a message to the server and if no error is returned, then it is considered as sent (by default).

chatDialog.send(message) { (error) in
    if error == nil {
        // status - 'sent'
    }
}
QBChatDialog *chatDialog = ...;
[chatDialog sendMessage:message completionBlock:^(NSError * _Nullable error) {
    if(!error) {
        //status - 'sent'
    }
}];

🚧

You should enable Stream Management before you do the login() because the Stream Management is initialized while Chat login is performed.

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

Delivered status

To track the message delivered event, the chatDidDeliverMessage(messageID:dialogID:) method of the delegate is used.

// ...
QBChat.instance.addDelegate(self)
// ...
    
//MARK: QBChatDelegate
func chatDidDeliverMessage(withID messageID: String, dialogID: String, toUserID userID: UInt) {
    
}
// ...
[QBChat.instance addDelegate:self];
// ...
    
//MARK: QBChatDelegate
- (void)chatDidDeliverMessageWithID:(NSString *)messageID dialogID:(NSString *)dialogID toUserID:(NSUInteger)userID {
    
}

The SDK sends a notification about the delivered status automatically when the message is received by the recipient. This is controlled by the markable parameter when you send a message using the send() method.

let dialog = ...
let markableMessage = QBChatMessage().markable
markableMessage.markable = true
markableMessage.text = "How are you today?"
    
dialog.send(markableMessage) { (error) in
    
}
QBChatDialog *dialog = ...;
QBChatMessage *markableMessage = [QBChatMessage markableMessage];
markableMessage.markable = YES;
markableMessage.text = @"How are you today?";
    
[dialog sendMessage:markableMessage completionBlock:^(NSError * _Nullable error) {
    
}];

Argument

Required

Description

markableMessage

yes

The message for which the SDK automatically sends a delivered status when the recipient receives it.

If markable is false or omitted, you can send a notification about the delivered status using the mark(asDelivered:) method.

let receivedMessage: QBChatMessage = ...

QBChat.instance.mark(asDelivered: receivedMessage) { (error) in
    
}
QBChatMessage *receivedMessage = ...;

[QBChat.instance markAsDelivered:receivedMessage completion:^(NSError * _Nullable error){
    
}];

Argument

Required

Description

receivedMessage

yes

A message received from the dialog participant.

You can also send a notification about the delivered status via REST API.

let dialog = ...
let dialogID = dialog.id
let receivedMessage: QBChatMessage = ...
let receivedMessageID: String = receivedMessage.id
let markMessagesAsDeliveredSet = Set<String>([receivedMessageID])

QBRequest.markMessages(asDelivered: markMessagesAsDeliveredSet, dialogID: dialogID, successBlock: { (response) in
    
}, errorBlock: { (response) in
    
})
QBChatDialog *dialog = ...;
NSString *dialogID = dialog.ID;
QBChatMessage *receivedMessage = ...;
NSString *receivedMessageID = receivedMessage.ID;
NSSet<NSString *> *markMessagesAsDeliveredSet = [NSSet setWithArray:@[receivedMessageID]

[QBRequest markMessagesAsDelivered:markMessagesAsDeliveredSet dialogID:dialogID successBlock:^(QBResponse * _Nonnull response) {
    
} errorBlock:^(QBResponse * _Nonnull response) {
    
}];

Argument

Required

Description

markMessagesAsDeliveredSet

yes

A set of received messages IDs.

dialogID

yes

The ID of the dialog.

Read status

To track the message read event, the chatDidReadMessage(messageID:dialogID:) method of the delegate is used.

// ...
QBChat.instance.addDelegate(self)
// ...

//MARK: QBChatDelegate
func chatDidReadMessage(withID messageID: String, dialogID: String, readerID: UInt) {
    
}
// ...
[QBChat.instance addDelegate:self];
// ...

//MARK: QBChatDelegate
- (void)chatDidReadMessageWithID:(NSString *)messageID dialogID:(NSString *)dialogID readerID:(NSUInteger)readerID {
    
}

To send a notification about the read status, use the read() method.

let receivedMessage: QBChatMessage = ...

QBChat.instance.read(receivedMessage) { (error) in
    
}
QBChatMessage *receivedMessage = ...;

[QBChat.instance readMessage:receivedMessage completion:^(NSError * _Nullable error) {
    
}

Argument

Required

Description

receivedMessage

yes

A message received from the chat participant.

You can also send a notification about the read status via REST API.

let dialog = ...
let dialogID = dialog.id
let receivedMessage: QBChatMessage = ...
let receivedMessageID: String = receivedMessage.id
let markMessagesAsReadSet = Set<String>([receivedMessageID])

QBRequest.markMessages(asRead: markMessagesAsReadSet, dialogID: dialogID, successBlock: { (response) in
    
}, errorBlock: { (response) in
    
})
QBChatDialog *dialog = ...;
NSString *dialogID = dialog.ID;
QBChatMessage *receivedMessage = ...;
NSString *receivedMessageID = receivedMessage.ID;
NSSet<NSString *> *markMessagesAsReadSet = [NSSet setWithArray:@[receivedMessageID]

[QBRequest markMessagesAsRead:markMessagesAsReadSet dialogID:dialogID successBlock:^(QBResponse * _Nonnull response) {
    
} errorBlock:^(QBResponse * _Nonnull response) {
    
}];

Argument

Required

Description

markMessagesAsReadSet

yes

A set of received messages IDs.

dialogID

yes

The ID of the dialog.

Is typing status

The following 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).

To track the message typing event, the onUserIsTyping() method of the delegate is used.

chatDialog.onUserIsTyping = { (userID: UInt) in
    
}
chatDialog.onUserIsTyping = ^(NSUInteger userID) {
    
};

To track the message stopped typing event, the onUserStoppedTyping() method of the delegate is used.

chatDialog.onUserStoppedTyping = { (userID: UInt) in
    
}
chatDialog.onUserStoppedTyping = ^(NSUInteger userID) {
    
};

Send the typing status to the private or group dialog using the sendIsTyping() method.

chatDialog.sendUserIsTyping()
[chatDialog sendUserIsTyping];

Send the stopped typing status to the private or group dialog using the sendUserStopTyping() method.

chatDialog.sendUserStopTyping()
[chatDialog sendUserStoppedTyping];

Add extra data to a message

You have the option to extend the message with additional fields. Specify one or more key-value items to the message. Using these items, you can implement the ability for a user to send self-location information to another user or notification messages signifying that a user has left a group, etc.

let message = QBChatMessage()
message.text = "How are you today?"
message.customParameters["save_to_history"] = true
message.customParameters["customParam1"] = "book"
message.customParameters["customParam2"] = "21"

let dialog = ...
dialog.send(message) { (error) in
   
}
QBChatMessage *message = [[QBChatMessage alloc] init];
message.customParams[@"type"] = @(dialog.type);
message.customParameters[@"save_to_history"] = @"1";
message.customParameters[@"customParam1"] = @"book";
message.customParameters[@"customParam2"] = @"21";

QBChatDialog *dialog = ...;
[dialog sendMessage:message completionBlock:^(NSError * _Nullable error) {
    
}];

Argument

Required

Description

message

yes

Specifies message fields that should be set.

Set the following fields of the message:

Field

Required

Description

text

no

Message text.

customParameters

no

Extra data. Specify any key-value pairs. In each pair, the key and value are both string values.

Set save_to_history as true. The save_to_history specifies if the message will be saved on the server.

Attachments

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

let url = URL(fileURLWithPath:"file_path")
//for image
QBRequest.uploadFile(with: url, fileName: fileName, contentType: "image/png", isPublic: true, successBlock: { (response, uploadedBlob) in
    
    let attachment = QBChatAttachment()
    attachment.id = uploadedBlob.uid
    attachment.name = uploadedBlob.name
    //for image
    attachment.type = "image"
    attachment.url = uploadedBlob.publicUrl()
    
    let message = QBChatMessage()
    message.text = "Image Attachment"
    //Set attachment
    message.attachments = [attachment]
    //Send message with attachment
    chatDialog.send(message, completionBlock: { (error) in  
    })
}, statusBlock: { (request, status)  in
    //Update UI with upload progress
}, errorBlock: { (response) in
    //show upload error
})
NSURL *fileUrl = [NSURL fileURLWithPath:@"file_path"]; //Local file url
//for image
[QBRequest uploadFileWithUrl:fileUrl fileName:@"image.png" contentType:@"image/png" isPublic:YES successBlock:^(QBResponse * _Nonnull response, QBCBlob * _Nonnull blob) {
    //Create attachment
    QBChatAttachment *attachment = [[QBChatAttachment alloc] init];
    attachment.ID = blob.UID;
    //for image
    attachment.type = @"image";
    attachment.url = blob.publicUrl;
    //Create message
    QBChatMessage *message = [[QBChatMessage alloc] init];
    message.text = @"Image attachment";
    //Set attachment
    message.attachments = @[attachment];
    //Send message with attachment
    [chatDialog sendMessage:message completionBlock:^(NSError * _Nullable error) {}];
} statusBlock:^(QBRequest * _Nonnull request, QBRequestStatus * _Nonnull status) {
    //Update UI with upload progress
} errorBlock:^(QBResponse * _Nonnull response) {
    //show upload error
}];

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

func chatDidReceive(_ message: QBChatMessage) {
    if let attachment = message.attachments?.first,
        let uid = attachment.id {
        QBRequest.downloadFile(withUID: uid, successBlock: { (response, data) in
            //process file data
        }, statusBlock: { (response, status) in
            //Update UI with dowonload progress
        }, errorBlock: { (response) in
            //show download error
        })
    }
}
- (void)chatDidReceiveMessage:(QBChatMessage *)message {
    QBChatAttachment *attachment = message.attachments.firstObject;
    [QBRequest downloadFileWithUID:attachment.ID successBlock:^(QBResponse * _Nonnull response, NSData * _Nonnull fileData) {
        //process file data
    } statusBlock:^(QBRequest * _Nonnull request, QBRequestStatus * _Nonnull status) {
        //Update UI with download progress
    } errorBlock:^(QBResponse * _Nonnull response) {
        //show download error
    }];
}

Update message

Update the message text using the updateMessage() method.

let messageId = "5b23aa4f5d0b0be0900041aa"
let text = "Edited text"
let dialogId = "5356c64ab35c12bd3b108a41"
QBRequest.updateMessage(withID: messageId, text: text, dialogID: dialogId, successBlock: { (response) in

}, errorBlock: { (response) in

})
NSString *messageId = @"5b23aa4f5d0b0be0900041aa";
NSString *text = @"Edited text";
NSString *dialogId = @"5356c64ab35c12bd3b108a41";
[QBRequest updateMessageWithID: messageId text: text dialogID: dialogId successBlock:^(QBResponse * _Nonnull response) {

} errorBlock:^(QBResponse * _Nonnull response) {

}];

Delete message

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

let messages: Set<String> = ["5b23aa4f5d0b0be0900041aa", "bc23aa4f5d0b0be0900041ad"]
QBRequest.deleteMessages(withIDs: messages, forAllUsers: false, successBlock: { (response) in
            
}, errorBlock: { (response) in
    
})
NSSet *messages = [NSSet setWithArray:@[@"5b23aa4f5d0b0be0900041aa", @"bc23aa4f5d0b0be0900041ad"]];
[QBRequest deleteMessagesWithIDs:messages forAllUsers:NO successBlock:^(QBResponse * _Nonnull response) {
    
} errorBlock:^(QBResponse * _Nonnull response) {
    
}];

Offline messaging

The offline messaging functionality allows for customizing automatic push notifications displayed on a user's device when they are offline. In other words, if your opponent is offline when you are writing a message, they can automatically receive a push notification.

πŸ“˜

Note

Make sure to subscribe your users to pushes using SDKs. Review Push Notifications section for more details.

Offline messages are customized from the Dashboard. Just follow Dashboard => YOUR_APP => Chat => Offline messaging directory to locate offline messaging settings.

Here you will find the following settings:

  • Enable automatic push notifications for offline users - check it to receive push notifications from the server automatically.
  • Offline messaging text - text of your push notification.
  • Templates - set push notification template here. Use template variables to engage your push message.
  • Badge counter - set badge counter to include counter info into your push message. Useful to include unread counter - the number of unread messages a user has.
  • Sound - set push notification sound (for iOS only).
  • Category - describes "actions" that should be presented in the app notification in various views (for iOS only).
  • Content Available - enable it to indicate that new content is available (for iOS only).
  • Mutable content - enable it to modify the content of newly delivered notifications before the user is alerted. Use a notification service app extension to be able to modify the content of the notification. If the option is enabled, the system passes the notification to the service app extension for the subsequent modification of the notification payload before the actual delivery (for iOS only).

🚧

Currently, push notifications are supported in a mobile environment only.

πŸ“˜

Set save_to_history=1 when sending messages to apply offline pushes. Review this section for more details.

Send system messages

There is a way to send system messages to other users about some events. For example, a system message can be sent when a user has joined or left a group dialog. System messages are handled over a separate channel and are not mixed up with regular chat messages. Thus, they are handled by chatDidReceiveSystemMessage() callback of QBChatDelegate. See this section to learn how to add QBChatDelegate.

System messages are also not shown in the dialog history and, consequently, are not stored on the server. This means that these messages will be delivered only to online users. Send system messages using the sendSystemMessage() method.

enum MessageType : String {
    case createGroupDialog = "1"
    case addUsersToGroupDialog = "2"
    case leaveGroupDialog = "3"
}

var message: QBChatMessage = QBChatMessage()
let params = NSMutableDictionary()
params["notification_type"] = MessageType.leaveGroupDialog.rawValue
params["dialog_id"] = "5356c64ab35c12bd3b108a41"
message.customParameters = params
message.recipientID = 344

 
QBChat.instance.sendSystemMessage(message) { (error) in
}
 
 
#pragma mark -
#pragma mark QBChatDelegate
 
func chatDidReceiveSystemMessage(message: QBChatMessage!) {
 
}
typedef NS_ENUM(NSUInteger, NotificationMessageType) {
    NotificationMessageTypeCreate = 1,
    NotificationMessageTypeAdding = 2,
    NotificationMessageTypeLeave = 3
};

QBChatMessage *message = [QBChatMessage message];
 
NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"notification_type"] = [NSString stringWithFormat:@"%@", @(NotificationMessageTypeLeave)];
params[@"dialog_id"] = @"5356c64ab35c12bd3b108a41";
[message setCustomParameters:params];
 
[message setRecipientID:344];
 
[[QBChat instance] sendSystemMessage:message completion:^(NSError * _Nullable error) {
 
}];
 
 
#pragma mark -
#pragma mark QBChatDelegate
 
- (void)chatDidReceiveSystemMessage:(QBChatMessage *)message{
 
}

Parameters

Description

message

Specifies system message fields that should be set.

Set the following fields of the message:

Fields

Required

Description

recipientID

yes

ID of the recipient.

customParameters

no

Extra data. Specify one or more key-value pairs. In each pair, the key and value are both string values.

Check if a user is online

This feature provides visibility whether the user is online or offline in real-time. You can check user presence either using a Contact List or Dialog.

Contact List

The chatDidReceiveContactItemActivity(_ userID:isOnline:status:) method of a delegate is called in case the online status of a user from the contact list has been changed. It can be applied only if the Contact List is implemented - when both users appear in each other's contact list having accepted the invitation to become friends.

//MARK: QBChatDelegate
func chatDidReceiveContactItemActivity(_ userID: UInt, isOnline: Bool, status: String?) {
    
}
//MARK: QBChatDelegate
- (void)chatDidReceiveContactItemActivity:(NSUInteger)userID isOnline:(BOOL)isOnline status:(NSString *)status {
    
}

Dialog

You can also obtain online/offline user status in real-time via chatDialog. Call requestOnlineUsers() method to get the list of users who are joined to the room. As a result, a completion block with an array of user IDs or failure error is called.

chatDialog.requestOnlineUsers { (onlineUsersIDs, error) in
    
}
[chatDialog requestOnlineUsersWithCompletionBlock:^(NSMutableArray<NSNumber *> *onlineUsers, NSError *error) {
    
}];

Call onJoinOccupant() method whenever an occupant has joined to the current Group or Public group dialog.

chatDialog.onJoinOccupant = { (userID) in
    
}
chatDialog.onJoinOccupant = ^(NSUInteger userID) {

};

Call onLeaveOccupant() method whenever an occupant has left the current Group or Public group dialog.

chatDialog.onLeaveOccupant = { (userID) in
    
}
chatDialog.onLeaveOccupant = ^(NSUInteger userID) {
    
};

Contact list

The Contact List API is rather straightforward. A user A sends a request to become "friends" with a user B. The user B accepts the friend request. And now the user A and B appear in each other roster.

Access contact list

The following function gives you access to all contact list items.

// array of accepted contacts
let contacts = QBChat.instance.contactList?.contacts

// array of pending requests
let pendingRequests = QBChat.instance.contactList?.pendingApproval
// array of accepted contacts
NSArray *contacts = QBChat.instance.contactList.contacts;

// array of pending requests
NSArray *pendingApproval = QBChat.instance.contactList.pendingApproval;

Add user to your contact list

To add a user to the contact list, use the following snippet.

let userID: UInt = 34
QBChat.instance.addUser(toContactListRequest: userID) { (error) in
    
}
NSUInteger userID = 34;
[QBChat.instance addUserToContactListRequest:userID completion:^(NSError * _Nullable error) {
    
}];

πŸ“˜

Maximum number of contacts is 300.

The QBChat instance will call its delegate’s chatDidReceiveContactAddRequest(fromUser:) method and the user will receive the request to be added to the contact list.

//MARK: QBChatDelegate
func chatDidReceiveContactAddRequest(fromUser userID: UInt) {
    
}
//MARK: QBChatDelegate
- (void)chatDidReceiveContactAddRequestFromUser:(NSUInteger)userID {
    
}

Confirm the contact request

To confirm the request, use confirmAddContactRequest() method.

QBChat.instance.confirmAddContactRequest(userID) { (error) in
    
}
[QBChat.instance confirmAddContactRequest:userID completion:^(NSError * _Nullable error) {
    
}];

The QBChat instance will call chatDidReceiveAcceptContactRequest(fromUser:) delegate method and this user will be informed that you have accepted the contact request.

//MARK: QBChatDelegate
func chatDidReceiveAcceptContactRequest(fromUser userID: UInt) {
    
}
//MARK: QBChatDelegate
- (void)chatDidReceiveAcceptContactRequestFromUser:(NSUInteger)userID {
    
}

Reject the contact request

To reject the request, use the rejectAddContactRequest() method.

QBChat.instance.rejectAddContactRequest(userID) { (error) in
    
}
[QBChat.instance rejectAddContactRequest:userID completion:^(NSError * _Nullable error) {
    
}];

The QBChat instance will call its chatDidReceiveRejectContactRequest(fromUser:) delegate method and this user will be informed that you have declined the contact request.

//MARK: QBChatDelegate
func chatDidReceiveRejectContactRequest(fromUser userID: UInt) {
    
}
//MARK: QBChatDelegate
- (void)chatDidReceiveRejectContactRequestFromUser:(NSUInteger)userID {
    
}

Remove user from the contact list

To remove a previously added user from the contact list, use the following method.

QBChat.instance.removeUser(fromContactList: 34) { (error) in
    
}
[QBChat.instance removeUserFromContactList:34 completion:^(NSError * _Nullable error) {
    
}];

Contact list updates

You can also track contact list updates in a real time by using delegates.

//MARK: QBChatDelegate
func chatContactListDidChange(_ contactList: ContactList) {
    
}
//MARK: QBChatDelegate
- (void)chatContactListDidChange:(QBContactList *)contactList {
    
}

Privacy (black) list

Privacy list API allows enabling or disabling communication with other users in a chat. You can create, modify, delete privacy lists or define a default list.

πŸ“˜

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

Create privacy list

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

let userID: UInt = 34
let privateChatPrivacyItem = QBPrivacyItem.init(privacyType: .userID, userID: userID, allow: false)
privateChatPrivacyItem.mutualBlock = true
let groupChatPrivacyItem = QBPrivacyItem.init(privacyType: .groupUserID, userID: userID, allow: false)
let privacyList = QBPrivacyList.init(name: "PrivacyList", items: [privateChatPrivacyItem, groupChatPrivacyItem])
//Setting privacy list
QBChat.instance.setPrivacyList(privacyList)
NSUInteger userID = 34;
QBPrivacyItem *privateChatPrivacyItem =
[[QBPrivacyItem alloc] initWithPrivacyType:QBPrivacyTypeUserID userID:userID allow:NO];
privateChatPrivacyItem.mutualBlock = YES;
QBPrivacyItem *groupChatPrivacyItem =
[[QBPrivacyItem alloc] initWithPrivacyType:QBPrivacyTypeGroupUserID userID:userID allow:NO];
QBPrivacyList *privacyList =
[[QBPrivacyList alloc] initWithName:@"PrivacyList" items:@[privateChatPrivacyItem,groupChatPrivacyItem]];
//Setting privacy list
[QBChat.instance setPrivacyList:privacyList];

If the privacy list is set successfully, the QBChat instance will call chatDidSetPrivacyList(withName:) delegate method.

//MARK: QBChatDelegate
func chatDidSetPrivacyList(withName name: String) {
    
}
//MARK: QBChatDelegate
- (void)chatDidSetPrivacyListWithName:(NSString *)name {
    
}

In case of error the QBChat instance will call
chatDidNotSetPrivacyList(withName:error:) delegate method.

//MARK: QBChatDelegate
func chatDidNotSetPrivacyList(withName name: String, error: Error) {
    
}
//MARK: QBChatDelegate
- (void)chatDidNotSetPrivacyListWithName:(NSString *)name error:(NSError *)error {
    
}

πŸ“˜

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

Activate privacy list

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

QBChat.instance.setDefaultPrivacyListWithName("PrivacyList")
[QBChat.instance setDefaultPrivacyListWithName:@"PrivacyList"];

If the privacy list is activated successfully, the QBChat instance will call chatDidSetDefaultPrivacyList(withName:) delegate method.

//MARK: QBQBChatDelegate
func chatDidSetDefaultPrivacyList(withName name: String) {
    
}
//MARK: QBChatDelegate
- (void)chatDidSetDefaultPrivacyListWithName:(NSString *)name {
    
}

Otherwise, the QBChat instance will call chatDidNotSetDefaultPrivacyList(withName:error:) delegate method.

//MARK: QBChatDelegate
func chatDidNotSetDefaultPrivacyList(withName name: String, error: Error) {
    
}
//MARK: QBChatDelegate
- (void)chatDidNotSetDefaultPrivacyListWithName:(NSString *)name error:(NSError *)error {
    
}

Update privacy list

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 a new privacy list instead of the current one, you should decline the current default list first.
//Deactivating privacy list before update
QBChat.instance.setDefaultPrivacyListWithName(nil)
//Some updates here
//....
//Activating privacy list
QBChat.instance.setDefaultPrivacyListWithName("PrivacyList")
//Deactivating privacy list before update
[QBChat.instance setDefaultPrivacyListWithName:nil];
//Some updates here
//....
//Activating privacy list
[QBChat.instance setDefaultPrivacyListWithName:@"PrivacyList"];

Retrieve privacy lists

To get a list of all your privacy lists names, use the following request.

QBChat.instance.retrievePrivacyListNames()
[QBChat.instance retrievePrivacyListNames];

If the privacy list names are retrieved successfully, the QBChat instance will call chatDidReceivePrivacyListNames() delegate method.

//MARK: QBChatDelegate
func chatDidReceivePrivacyListNames(_ listNames: [String]) {
    
}
//MARK: QBChatDelegate
- (void)chatDidReceivePrivacyListNames:(NSArray<NSString *> *)listNames {
    
}

Otherwise, the QBChat instance will call chatDidNotReceivePrivacyListNamesDue(toError:) delegate method.

//MARK: QBChatDelegate
func chatDidNotReceivePrivacyListNamesDue(toError error: Error) {
    
}
//MARK: QBChatDelegate
- (void)chatDidNotReceivePrivacyListNamesDueToError:(NSError *)error {
    
}

Retrieve privacy list by name

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

QBChat.instance.retrievePrivacyList(withName: "PrivacyList")
[QBChat.instance retrievePrivacyListWithName:@"PrivacyList"];

If the privacy list is retrieved successfully, the QBChat instance will call chatDidReceive(_ privacyList:) its delegate method.

//MARK: QBChatDelegate
func chatDidReceive(_ privacyList: QBPrivacyList) {
    
}
//MARK: QBChatDelegate
- (void)chatDidReceivePrivacyList:(QBPrivacyList *)privacyList {
    
}

Otherwise, the QBChat instance will call chatDidNotReceivePrivacyList(withName:error) delegate method.

//MARK: QBChatDelegate
func chatDidNotReceivePrivacyList(withName name: String, error: Error) {
    
}
//MARK: QBChatDelegate
- (void)chatDidNotReceivePrivacyListWithName:(NSString *)name error:(NSError *)error {
    
}

Remove privacy list

To delete a list, you can call the method below or you can edit a list and set items to nil.

QBChat.instance.removePrivacyList(withName: "PrivacyList")
[QBChat.instance removePrivacyListWithName:@"PrivacyList"];

If the privacy list is removed successfully, the QBChat instance will call chatDidRemovedPrivacyList(withName:) delegate method.

//MARK: QBChatDelegate
func chatDidRemovedPrivacyList(withName name: String) {
    
}
//MARK: QBChatDelegate
- (void)chatDidRemovedPrivacyListWithName:(NSString *)name {
    
}

πŸ“˜

Before deleting the privacy list, you should decline it.

Blocked user attempts to communicate with user

A user can be blocked in 1-1 dialog and group dialog. In this case, the blocked user receives an error when trying to send a message in a 1-1 dialog and receives nothing when trying to send a message in group dialog.

chatDialog.onBlockedMessage = { (error) in
    
}
chatDialog.onBlockedMessage = ^(NSError * _Nullable error) {
    
};

Updated 5 months ago


What's Next

Video Calling

Advanced


Learn how to manage message statuses, attachments, contact list, offline messaging, and privacy list.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.