-
Notifications
You must be signed in to change notification settings - Fork 0
Latest API Documentation
let getUserSearchQuery = QueryBuilder.instance.createUserListFilter()
getUserSearchQuery.searchQuery = query
getUserSearchQuery.limit = defaultLimit
getUserSearchQuery.skip = 0
CHService.main.getUsersList(queryFilter: getUserSearchQuery, completion: {(users,error) in
// Do your Stuff here
})
CHService.main.getUser(userId:"20456",completion:{(user,error) in
// Do your Stuff here
})
CHService.main.blockUser(userId:"20456",completion:{(status,error) in
// Do your Stuff here
})
let blockedUsersQuery = QueryBuilder.instance.createBlockedUsersListFilter()
blockedUsersQuery.limit = 30
blockedUsersQuery.skip = 0
CHService.main.getBlockedUsers(queryFilter:blockedUsersQuery,completion:{(users,error) in
// Do your stuff here
})
let friendsFilter = QueryBuilder.createUserFriendsListFilter()
friendsFilter.online = true
friendsFilter.limit = 30
friendsFilter.skip = 0
friendsFilter.includeBlocked = true
friendsFilter.skipUserIds = "20456,20576,20789"
friendsFilter.searchQuery = "Leo"
friendsFilter.sort = .DESC
CHService.main.getFriendsList(queryFilter:friendsFilter,completion:{(users,error) in
// Do your Stuff Here
})
let friendsCountFilter = QueryBuilder.instance.createUserFriendsCountFilter()
friendsCountFilter.online = false
friendsCountFilter.includeBlocked = true
friendsCountFilter.searchQuery = "James"
CHService.main.getFriendsCount(queryFilter:friendsCountQueryFilter,completion:{(count,error) in
// Do your stuff here
})
CHService.main.unblockUser(userId:"20456",completion:{(status,error) in
// Do your stuff here
})
let userCountsFilter = QueryBuilder.createUserFriendsCountFilter()
userCountsFilter.includeBlocked = true
userCountsFilter.online = true
userCountsFilter.searchQuery = "James"
CHService.main.getUserCounts(queryFilter:userCountsFilter,completion:{(count,error) in
// Do your stuff here
})
CHService.main.getBlockedUsersCount(queryFilter:friendsCountFilter,completion:{(count,error) in
// Do your stuff here
})
let friendsQuery = QueryBuilder.instance.createUserFriendsListFilter()
friendsQuery.online = true
friendsQuery.limit = defaultLimit
friendsQuery.skip = 0
CHService.main.getOnlineUsers(queryFilter: friendsQuery, completion: {(users,error) in
// Do your stuff here
})
let visibility = false
CHService.main.changeUserVisibility(isVisible: visibility, completion: {(user,error) in
// Do your stuff here
})
CHService.main.changeNotificationSetting(isNotificationOn: false, completion: {(user,error) in
// Do your stuff here
})
let textBody = "Hello, How are you?"
var params = [String:Any]()
params.updateValue(UUID().uuidString,forKey:"id")
params.updateValue(Channelize.currentUserId()!,forKey:"ownerId")
if currentConversation != nil{
params.updateValue(currentConversation.id!,forKey:"chatId")
} else{
params.updateValue(RECIPIENT_ID,forKey:"userId")
}
CHService.main.sendTextmessage(textMessage:textBody,messageParams:params,conversation:currentConversation,completion:{(message,error) in
// Do your Stuff here
})
CHService.main.sendFileMessage(messageParams: params, fileParams: params, thumbnailData: nil, fileData: audioData, messageType: .AUDIO, conversation: self?.chat, completion: {(message,error)
// Do your Stuff here
})
// quotedMessage is the message which you want to quote
let messageText = "Hello, this is a quoted message"
var params = [String:Any]()
params.updateValue(UUID().uuidString,forKey:"id")
params.updateValue(Channelize.currentUserId()!,forKey:"ownerId")
params.updateValue(conversation.id,forKey:"chatId")
var quotedParams = [String:Any]()
quotedParams.updateValue(quotedMessage.id,forKey:"id")
quotedParams.updateValue(quotedMessage.attachmentType,forKey:"attachmentType")
quotedParams.updateValue(quotedMessage.ownerId,forKey:"ownerId")
let owner = ["displayName":quotedMessage.userDisplayName,"id":quotedMessage.ownerId]
quotedParams.updateValue(owner,forKey:"owner")
quotedParams.updateValue(quotedMessage.contentType,forKey:"contentType")
switch quotedMessage.attachmentType{
case "text":
quotedParams.updateValue(quotedMessage.body!, forKey: "body")
case "image","video","audio":
let attachment = ["fileUrl":quotedMessage.file?.fileUrl]
quotedParams.updateValue(attachment, forKey: "attachment")
case "sticker","gif":
quotedParams.updateValue(quotedMessage.previewUrl!, forKey: "downsampledUrl")
case "location":
let data = ["latitude":quotedMessage.messageData?.latitude,"longitude":modelMessage.messageData?.longitude]
quotedParams.updateValue(data, forKey: "data")
}
CHService.main.sendQuotedMessage(messageParams:params,messageText:messageText,quotedMessageId:quotedMessage.id,quotedMessageParams:quotedParams,conversation:conversation,completion:{(message,error) in
})
var params = [String:Any]()
params.updateValue(UUID().uuidString,forKey:"id")
params.updateValue(Channelize.currentUserId()!,forKey:"ownerId")
params.updateValue(conversation.id,forKey:"chatId")
var locationParams = [String:Any]()
locationParams.updateValue(53.2734,forKey:"latitude")
locationParams.updateValue(7.778,forKey:"longitude")
locationParams.updateValue("Madison Square Garden",forKey:"title")
locationParams.updateValue("4 Pennsylvania Plaza, New York, NY 10001, USA",forKey:"address")
CHService.main.sendLocationMessage(messageParams:params,locationParams:locationParams,conversation:conversation,completion: {(message,error) in
// Do your Stuff here
})
var params = [String:Any]()
params.updateValue(UUID().uuidString,forKey:"id")
params.updateValue(Channelize.currentUserId()!,forKey:"ownerId")
params.updateValue(conversation.id,forKey:"chatId")
var gifStickParams = [String:Any]()
gifStickParams.updateValue("https://media1.giphy.com/media/Zantw7qPmMaZZJBrzc/200.gif",forKey:"originalUrl")
gifStickParams.updateValue("https://media1.giphy.com/media/Zantw7qPmMaZZJBrzc/200_s.gif",forKey:"stillUrl")
gifStickParams.updateValue("https://media1.giphy.com/media/Zantw7qPmMaZZJBrzc/200_d.gif",forKey:"downsampledUrl")
CHService.main.sendGIFStickerMessage(messageParams: params, gifStickerParams: gifStickParams,messageType: .GIF conversation: conversation, completion: {(message,error) in
// Do your Stuff here
})
let messageCountQuery = QueryBuilder.createConversationMessageCountFilter()
messageCountQuery.attachmentType = "image,video,text,location,gif,sticker,audio"
messageCountQuery.contentType = 0 // Possible Values 0,1,2,3
messageCountQuery.ownerId = 20456
CHService.main.addGroupAdmin(chatId:"2004589",userId:"55",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
let getMessageQuery = QueryBuilder.instance.createConversationMessageFilter()
getMessageQuery.limit = 30
getMessageQuery.skip = 0
getMessageQuery.attachmentType = "image,audio,video"
getMessageQuery.contentType = 0
getMessageQuery.sort = .DESC
CHService.main.getMessages(queryFilter: getMessageQuery, chatId: self.chatId!, completion: {(messages,error) in
guard error == nil else {
print("Error in Getting Messages")
return
}
"Do your stuff with Messages"
})
To delete messages, call deleteMessages
function of CHService
class. Parameters needed are messageIds
as string array of message ids
///
/// - parameter messageIds: Array of Message Ids
/// - parameter completion: Completion Handler with Status as Bool and optional Error
///
/// ## Usage:
let messageIds = ["d37175a3-1926-45f9-a302-3b5b238850ff","d37175a3-1926-45f9-a302-3b5b23885012"]
CHService.main.deleteMessages(messageIds: messageIds, completion: {(status,error) in
if status{
print("Messages Deleted")
} else{
print("Failed")
}
})
To forward call forwardMessages
function of CHService
class.
You can Forward Multiple Message to multiple users and Groups. Pass userIds
as an array of String containing userIds, groupsIds
as an array of String containing groups ids and messageIds
as an array of String containing message ids to be forwarded
///
/// You can Forward Multiple Message to multiple users and Groups. Pass `userIds` as an array of String containing userIds, `groupsIds` as an array of String containing groups ids and `messageIds` as an array of String containing message ids to be forwarded
///
/// - parameter userIds: array of String containing userIds
/// - parameter groupIds: array of String containing groups ids
/// - parameter messagesIds: array of String containing message ids
/// - parameter completion: Completion handler with a Bool value for API call status and Optional Error
///
/// ## Usage
let userIds = ["20465","20573","20984"]
let groupIds = ["30465","30573","30984"]
let messageIds = ["d37175a3-1926-45f9-a302-3b5b238850ff","d37175a3-7890-45f9-a302-3b5b23885192"]
CHService.main.forwardMessages(userIds: userIds, groupIds: groupIds, messagesIds: messageIds, completion: {(status,error) in
if status{
print("Message Forwared")
} else{
print("Failed")
}
})
To get total unread message count, call getUnreadMessageCounts
function of CHService
class. Completion handler will provide count of unread message and optional error.
CHService.main.getUnreadMessageCounts(completion: {(count,error) in
guard error == nil else{
print("Error")
return
}
})
To mark a message as read, call markMessageAsRead
function of CHService
class. Parameters needed are messageId
as id of the respective message. Completion handler will provide a Bool
value as status of API call and an optional error.
///
/// - parameter messageId: Id of the message to be mark as Read
/// - parameter completion: Completion handler with a Bool value for API call status and Optional Error
///
/// ## Usage
let id = "d37175a3-1926-45f9-a302-3b5b238850ff"
CHService.main.markMessageAsRead(messageId:id,completion: {(status,error) in
if status{
print("Message Forwared")
} else{
print("Failed")
}
})
let conversationQuery = QueryBuilder.instance.createConversationListFilter()
conversationQuery.inclued = "membersList"
conversationQuery.limit = defaultLimit
conversationQuery.offset = offset
CHService.main.getChats(queryFilter: conversationQuery, completion: {(conversations,error) in
// Do your Stuff Here
})
To leave a group conversation call addGroupAdmin
method of CHService
class. Parameters needed are chatId
as id of respective group conversation and userId
as id of the user you want to make admin. Completion handler will provide you a bool value and an optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter userId: Id of the user whome you want to make Admin
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Usage:
CHService.main.addGroupAdmin(chatId:"2004589",userId:"55",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To remove members from a group conversation call removeGroupMember
method of CHService
class. Parameters needed are chatId
as id of respective group conversation and userId
as id of the user you want to remove. Completion handler will provide you a bool value and an optional error. This call should be made only from an admin of the group.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter userId: Id of the user whome you want to remove from Group Conversation
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Notes:
/// Must be called from Admin of the Group
/// ## Usage:
CHService.main.removeGroupMember(chatId:"2004589",userId:"55",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To leave a group conversation call leaveConversation
method of CHService
class. Parameters needed are chatId
as id of respective group conversation.Completion handler will provide you a bool value and an optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Usage:
CHService.main.leaveConversation(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To clear a conversation call clearConversation
method of CHService
class. Parameters needed are chatId
as id of respective conversation.Completion handler will provide you a bool value and an optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Notes:
/// It will only clear all Messages. It will not delete the Conversation
/// ## Usage:
CHService.main.clearConversation(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To delete a conversation call deleteConversation
method of CHService
class. Parameters needed are chatId
as id of respective conversation.Completion handler will provide you a bool value and an optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Notes:
/// It will Delete all Messages and conversation
/// ## Usage:
CHService.main.deleteConversation(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To add members to a coversation, call addMembersToConversation
function of CHService
class. This method should be called from an admin of the group. Parameters needed are chatId
as id of respective conversation, userIds
as an string array containing members ids. Completion handler will give you a Bool
value and an optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter userIds: A string Array object containin member Ids
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Notes:
/// Must be called from Admin of the Group
/// ## Usage:
let chatId = "2004859"
let usersIds = ["20456","20152"]
CHService.main.addMembersToConversation(chatId:chatId,userIds:usersIds,completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To mark all messages read of a conversation, call markAllMessageAsRead
function of CHService
class. Parameters needed are chatId
as id of respective conversation. Completion handler will provide a Bool value and an optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Usage:
CHService.main.markAllMessageAsRead(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To get members of a conversation, call getConversationMembers
function of CHService
class. Parameters needed are chatId
as id of respective conversation. Completion handler will provide you an array object of CHUser
and optional error.
///
/// - parameter chatId: Conversation or Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have an array of `CHUser` object and optional Error
/// ## Usage:
CHService.main.getConversationMembers(chatId:"2004589",completion:{(users,error) in
guard error == nil else {
print("Error occured")
return
}
"Do your Stuff with Users List"
})
To update title of a group call updateConversationTitle
function of CHService
class. Parameters needed are title
as New title of the group, chatId
as the conversation id of respective group. Completion handler will return a Bool value and an optional error
///
/// - parameter title: New Title Of the Group
/// - parameter chatId: Id of the Group
/// - parameter completion: The closure called when the API response comes. Closure will have Bool response and a Optional Error
/// ## Usage:
CHService.main.updateConversationTitle(title:"New Title",chatId:"205578344",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To mute or unmute a conversation call muteUnmuteConversation
function of CHService
class. Parameters needed are chatId
as id of the respective conversation, isMuted
as Bool value. Completion handler will give you status as true or false and an option error
///
/// - parameter chatId: Conversation or Group Id
/// - parameter isMuted: True or False. True => Mute Conversation False => Unmute Conversation
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Usage:
CHService.main.muteUnmuteConversation(chatId:"2004589",userId:"55",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
Get a conversation Object with a conversation Id. Parameters needed are chatId
as id of the Conversation
///
/// - parameter chatId: Conversation or Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have CHConversation Object and a Optional Error
/// ## Usage:
CHService.main.getConversationWithId(chatId:"20456",completion:{(conversation,error) in
guard error == nil else{
print("Error in Getting Conversation")
return
}
"Do your Stuff Here with Conversation object"
})
Get a conversation Object related to a user. Parameters needed are recipientId
as id of the User. Important use when you are creating a one-to-one chat with a new user.
///
/// - parameter recipientId: User Id
/// - parameter completion: The closure called when the API response comes. Closure will have CHConversation Object and a Optional Error
///
/// ## Usage:
CHService.main.getConversationWithRecipientId(recipientId:"20456",completion:{(status,error) in
guard error == nil else{
print("Error in Getting Conversation")
return
}
"Do your Stuff Here with Conversation object"
})
To update a group Profile Photo call updateGroupProfilePhoto
function of CHService
class. Parameters needed are profileImageData
and groupId
as Group Conversation id.
///
/// - parameter profileImageData: Conversation or Group Id
/// - parameter groupId: Group Id
/// - parameter completion: The closure called when the API response comes. Closure will have Bool reponse and a Optional Error
/// ## Usage:
CHService.main.updateGroupProfilePhoto(profileImageData:imageData,groupId:"20000545938",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
To create a new Group Conversation call CHService
class createGroup
function. Parameters needed to create a group are groupTitle
,profileImageData
if want to create group with a profile photo, memberIds
as a String Array containing members ids. Completion handler will provide a CHConversation
object if group created successfully, else it will return error.
///
/// - parameter groupTitle: New Group Title
/// - parameter profileImageData: Group Profile Image Data [Optional]
/// - parameter memberIds: A string Array object containing User ids of Group
/// - parameter completion: The closure called when the API response comes. Closure will have CHConversation Object and a Optional Error
/// ## Usage:
CHService.main.createGroup(groupTitle:"New Group 51",profileImageData:imageData,memberIds:["20456","20657"],completion:{(conversation,error) in
guard error == nil else {
print("Error in Creating New Group")
return
}
"Do you stuff with conversation Object"
})