-
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"
})
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")
}
})
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")
}
})
CHService.main.getUnreadMessageCounts(completion: {(count,error) in
guard error == nil else{
print("Error")
return
}
})
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
})
CHService.main.addGroupAdmin(chatId:"2004589",userId:"55",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
CHService.main.removeGroupMember(chatId:"2004589",userId:"55",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
CHService.main.leaveConversation(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
CHService.main.clearConversation(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
CHService.main.deleteConversation(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
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"
}
})
CHService.main.markAllMessageAsRead(chatId:"2004589",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})
CHService.main.getConversationMembers(chatId:"2004589",completion:{(users,error) in
guard error == nil else {
print("Error occured")
return
}
"Do your Stuff with Users List"
})
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"
})