-
Notifications
You must be signed in to change notification settings - Fork 0
MQTT Subscriber Setup with Channelize API SDK
In IOS SDKs, we have implemented MQTT as the pub sub protocol that is user for delivering data.
To receive certain events happening in the conversations from Channelize server you need to register CHConversationDataDelegate
with it's unique ID.
You need to implement the following functions/events to keep getting the information related to the conversations.
// ViewController.swift
class ViewController: UIViewController, CHConversationDataDelegate {
override func viewdidLoad() {
// ...
Channelize.addConversationDelegate(self, identifier: UNIQUE_DELEGATE_ID)
// ...
}
func didGetChatInfo(conversation: CHConversation?) {
}
func didReceiveNewMessage(message: CHMessage?){
}
func didDeleteChat(conversation: CHConversation?){
}
func didClearChat(conversation: CHConversation?){
}
func didDeleteMessage(conversation: CHConversation?){
}
func didMemberAdded(conversation: CHConversation?){
}
func didMemberRemoved(conversation: CHConversation?){
}
func didAdminAdded(conversationId:String?, isAdmin:Bool, userId:String?){
}
func didMarkAsRead(messageId:String?,conversationId:String?,userId:String?,status:Int?,isMe:Bool){
}
func didChangeTypingStatus(conversationId:String?,userId:String?,isTyping:Bool){
}
func didMessagesDeleted(messageIds:[String],topic:String){
}
}
The following code shows how to remove the event data delegate.
Channelize.removeDelegate(forDelegateId: UNIQUE_DELEGATE_ID)
To receive certain events happening related to the users from Channelize server you need to register CHUserEventDelegate
with it's unique ID.
You need to implement the following functions/events to keep getting the information related to the users.
// ViewController.swift
class ViewController: UIViewController, CHUserEventDelegate {
override func viewdidLoad() {
// ...
Channelize.addUserDelegate(self, identifier: UNIQUE_DELEGATE_ID)
// ...
}
func didUserAdded(user: CHUser?) {
}
func didUserRemoved(user: CHUser?) {
}
func didChangeUserStatus(user: CHUser?){
}
func didUserBlocked(isMe:Bool,userId:String?){
}
func didUserUnblocked(isMe:Bool,user: CHUser?){
}
}
To receive certain events related to the server connection you need to register CHConnectionDelegate
with it's unique ID. You need to implement the following functions/events to keep getting the information related to the users.
// ViewController.swift
class ViewController: UIViewController, CHConnectionDelegate {
override func viewdidLoad() {
// ...
Channelize.addConnectionDelegate(self, identifier: UNIQUE_DELEGATE_ID)
// ...
}
func didStartReconnection(){
}
func didServerConnected(){
}
func didServerDisconnected(){
}
func didConnectionFailed(){
}
}