-
Couldn't load subscription status.
- Fork 0
Latest API Documentation
To get users list call getUsersList function of CHService class. You need to pass GetUserFilters object of QueryBuilder class. Assign variable to GetUserFilters object according to your requirement. Not assigning any variable will return default result. Variables are:
| Name | Type | Required | Description |
|---|---|---|---|
| isOnline | Bool | Optional | True to include only online user in result, false to Exclude online users. Default will include both in result |
| limit | Int | Optional | Variable to set limit of number of results in one API Call |
| skip | Int | Optional | Variable to set offset of Next API call like 0,30,60 |
| searchQuery | String | Optional | String value to filter search. Use it when you are searching for users |
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
})To get a user object with a particular id, call getUser function of CHService class. Parameters needed are:
| Name | Type | Required | Description |
|---|---|---|---|
| userId | String | Yes | Id of the respective user |
| completion | (CHUser?,Error?) | Yes | Completion handler with a optional CHUser object and an optional Error object |
CHService.main.getUser(userId:"20456",completion:{(user,error) in
// Do your Stuff here
})To block a user with a particular id, call blockUser function of CHService class. Parameters needed are:
| Name | Type | Required | Description |
|---|---|---|---|
| userId | String | Yes | Id of the respective user |
| completion | (Bool,Error?) | Yes | Completion handler with a Bool value as API status and an optional Error object |
CHService.main.blockUser(userId:"20456",completion:{(status,error) in
// Do your Stuff here
})To get blocked users list, call getBlockedUsers function of CHService class. Parameter required is GetBlockedUserFilters of QueryBuilder class. Assign variable to GetBlockedUserFilters object according to your requirement. Not assigning any variable will return default result. Variables are:
| Name | Type | Required | Description |
|---|---|---|---|
| limit | Int | Optional | Variable to set limit of number of results in one API Call |
| skip | Int | Optional | Variable to set offset of next api Call like 0,30,60 |
let blockedUsersQuery = QueryBuilder.instance.createBlockedUsersListFilter()
blockedUsersQuery.limit = 30
blockedUsersQuery.skip = 0
CHService.main.getBlockedUsers(queryFilter:blockedUsersQuery,completion:{(users,error) in
// Do your stuff here
})To get Friends List, call getFriendsList function of CHService class. Parameter needed is GetFriendsFilters object of QueryBuilder class. Assign variables to GetFriendsFilters object according to your needs. List of variables are
| Name | Type | Required | Description |
|---|---|---|---|
| isOnline | Bool | Optional | True to include only online user in result, false to Exclude online users. Default will include both in result |
| limit | Int | Optional | Variable to set limit of number of results in one API Call |
| skip | Int | Optional | Variable to set offset of next api Call like 0,30,60 |
| includeBlocked | Bool | Optional |
true to include blocked user in result, false to exclude. Not assigning will include all. |
| skipUserIds | String | Optional | String containing comma separated members ids to be skipped in result. Useful when adding members to a group, you can skip ids of current members of group |
| searchQuery | String | Optional | String value to search friends on the basis of name. |
| sort | OrderType |
Optional | Sortign order. either .DESC or .ASC
|
let friendsFilter = QueryBuilder.instance.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
})To get total friends cout, call getFriendsCount function of CHService class. Parameters needed are GetFriendsCountFilters object of CHService class. Assign variables to GetFriendsCountFilters object according to your need. List of variables are
| Name | Type | Required | Description |
|---|---|---|---|
| includeBlocked | Bool | Optional |
true to include blocked user in result, false to exclude. Not assigning will include all. |
| isOnline | Bool | Optional | True to include only online user in result, false to Exclude online users. Not assigning will include both in result |
| search | String | Optional | String value to search friends on the basis of name |
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
})To unblock a user, call unblockUser function of CHService class. Parameter needed are
| Name | Type | Required | Description |
|---|---|---|---|
| userId | String | Yes | Id of the respective user |
| completion | (Bool,Error?) | Yes | Completion handler with Bool value as API status and an optional Error object |
CHService.main.unblockUser(userId:"20456",completion:{(status,error) in
// Do your stuff here
})To get total blocked users count, call getBlockedUsersCount function of CHService class. Parameters needed are GetBlockedUserCountFilters object of CHService class. Assign variables to GetBlockedUserCountFilters object according to your need. List of variables are
| Name | Type | Required | Description |
|---|---|---|---|
| isOnline | Bool | Optional | True to include only online user in result, false to Exclude online users. Not assigning will include both in result |
| search | String | Optional | String value to search friends on the basis of name |
let blockedUsersCount = QueryBuilder.instance.createUserFriendsCountFilter()
blockedUsersCount.isOnline = false
blockedUsersCount.search = "James"
CHService.main.getBlockedUsersCount(queryFilter:friendsCountFilter,completion:{(count,error) in
// Do your stuff here
})To change a user visibility, call changeUserVisibility function of CHService class. Parameter needed are:
| Name | Type | Required | Description |
|---|---|---|---|
| isVisible | Bool | Optional | Bool value true for Visible, false for hidden |
| completion | (CHUser?,Error?) | Optional | Completion handler with optional CHUser object and an optional Error object |
let visibility = false
CHService.main.changeUserVisibility(isVisible: visibility, completion: {(user,error) in
// Do your stuff here
})To turn on and off notifications, call changeNotificationSetting function of CHService class. Parameter needed are
| Name | Type | Required | Description |
|---|---|---|---|
| isNotificationOn | Bool | Optional | Bool value true for turning on notifications, false for turning off |
| completion | (CHUser?,Error?) | Optional | Completion handler with optional CHUser object and an optional Error object |
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
})To send a location message, call sendFileMessage of CHService class. Parameters required are
| Name | Type | Required | Description |
|---|---|---|---|
| messageParams | [String:Any] | Yes | Message parameters id as unique id of message,ownerId as owner id, chatId as chat id if exist else recipient id |
| thumbnailData | Data | Optional | Send thumbnail data as an image data with size 180*180 for photo and video messages. Nil for audio Messages |
| fileData | Data | Yes | Data to be uploaded like image data, video data or audio data |
| messageType | CHMessageType | Yes | Type of Message. .IMAGE for photo messages, .VIDEO for video messages, .AUDIO for audio messages |
| conversation | CHConversation | Optional | Conversation object in which you are sending message |
| completion | (CHMessage?,Error?) | Yes | Completion handler with a optional CHMessage object and option Error object |
CHService.main.sendFileMessage(messageParams: params, thumbnailData: nil, fileData: audioData, messageType: .AUDIO, conversation: self?.chat, completion: {(message,error)
// Do your Stuff here
})To send a location message, call sendLocationMessage of CHService class. Parameters required are
| Name | Type | Required | Description |
|---|---|---|---|
| messageParams | [String:Any] | Yes | Message parameters id as unique id of message,ownerId as owner id, chatId as chat id if exist else recipient id |
| locationParams | [String:Any] | Yes | Location parameters containing latitude,longitude,title,address
|
| conversation | CHConversation |
Optional | Conversation object in which you are sending message |
| completion | (CHMessage?,Error?) | Yes | Completion Handler with optional message and Optional Error |
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
})To send a GIFs and Sticker messages, call sendGIFStickerMessage of CHService class. Parameters required are
| Name | Type | Required | Description |
|---|---|---|---|
| messageParams | [String:Any] | Yes | Message parameters id as unique id of message,ownerId as owner id, chatId as chat id if exist else recipient id |
| gifStickerParams | [String:Any] | Yes | GIF parameters containing originalUrl,stillUrl,downsampledUrl provided by GIPHY sdk |
| conversation | CHConversation |
Optional | Conversation object in which you are sending message |
| completion | (CHMessage?,Error?) | Yes | Completion Handler with optional message and Optional Error |
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
})To send a quoted messages, call sendQuotedMessage of CHService class. Parameters required are
| Name | Type | Required | Description |
|---|---|---|---|
| messageParams | [String:Any] | Yes | Message parameters id as unique id of message,ownerId as owner id, chatId as chat id if exist else recipient id |
| messageText | String | Yes | Text string for quoted message |
| quotedMessage | CHMessage | Yes | Message object which you want to quote |
| conversation | CHConversation |
Optional | Conversation object in which you are sending message |
| completion | (CHMessage?,Error?) | Yes | Completion Handler with optional message and Optional Error |
// 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")
let qMessage = self.conversation.messageWithId("d37175a3-1926-45f9-a302-3b5b238850ff")
CHService.main.sendQuotedMessage(messageParams:params,messageText:messageText,quotedMessage:qMessage,conversation:conversation,completion:{(message,error) in
})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:
| Name | Type | Required | Description |
|---|---|---|---|
| messageIds | [String] | Yes | Array of message ids to be deleted |
| completion | (Bool,Error?) | Yes | Completion handler with Bool value as API status and optional Error object |
/// ## 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
| Name | Type | Required | Description |
|---|---|---|---|
| userIds | [String] | Yes | Array of user ids whom message to be forwarded |
| groupIds | [String] | Yes | Array of groups conversation ids in which message to be forwarded |
| messagesIds | [String] | Yes | Array of message ids to be forwarded |
| completion | (Bool,Error?) | Yes | Completion handler with Bool value as API status and optional Error object |
/// ## 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.
| Name | Type | Required | Description |
|---|---|---|---|
| messageId | [String] | Yes | Array of message ids to be mark as read |
| completion | (Bool,Error?) | Yes | 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. This call should be made only from an admin of the group. Parameters needed are:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| userId | String | Yes | User id of the user |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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. This call should be made only from an admin of the group. Parameters needed are:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| userId | String | Yes | User id of the user |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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. It will only clear all Messages. It will not delete the Conversation. Parameters needed are
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| userIds | [String] | Yes | Array containing user ids |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Group conversation Id |
| completion | ([CHUsers]?,Error?) | Yes | Completion Handler with array of CHUser object and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| title | String | Yes | New title of the group |
| chatId | String | Yes | Respective Group conversation Id |
| completion | (Bool?,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## 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:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Conversation Id |
| isMuted | Bool | Yes | True to mute conversation, false to unmute a conversation |
| completion | (Bool?,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## Usage:
CHService.main.muteUnmuteConversation(chatId:"2004589",isMuted:true,completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})Get a conversation Object with a conversation Id. Parameters needed are:
| Name | Type | Required | Description |
|---|---|---|---|
| chatId | String | Yes | Respective Conversation Id |
| completion | (CHConversation?,Error?) | Yes | Completion Handler with optional CHConversation object and an optional error object |
/// ## 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. Important use when you are creating a one-to-one chat with a new user. Parameters needed are :
| Name | Type | Required | Description |
|---|---|---|---|
| recipientId | String | Yes | Respective User Id |
| completion | (CHConversation?,Error?) | Yes | Completion Handler with optional CHConversation object and an optional error object |
/// ## Usage:
CHService.main.getConversationWithRecipientId(recipientId:"20456",completion:{(conversation,error) in
guard error == nil else{
print("Error in Getting Conversation")
return
}
"Do your Stuff Here with Conversation object"
})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.
| Name | Type | Required | Description |
|---|---|---|---|
| groupTitle | String | Yes | Title of the new group |
| profileImageData | Data | Optional | Group Profile Image Data |
| memberIds | [String] | Yes | Array containing members ids |
| completion | (CHConversation?,Error?) | Yes | Completion Handler with optional group conversation object and an optional error object |
/// ## 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"
})To update a group Profile Photo call updateGroupProfilePhoto function of CHService class. Parameters needed are profileImageData and groupId as Group Conversation id.
| Name | Type | Required | Description |
|---|---|---|---|
| profileImageData | Data | Optional | Group Profile Image Data |
| groupId | String | Yes | Conversation of respective group |
| completion | (Bool,Error?) | Yes | Completion Handler with Bool value and an optional error object |
/// ## Usage:
CHService.main.updateGroupProfilePhoto(profileImageData:imageData,groupId:"20000545938",completion:{(status,error) in
if status{
"Do your Stuff Here"
} else {
"Operation Failed"
}
})