Users
This section contains the User operations that can be performed using iOS SDKs i.e Add/remove friends, block user, unblock user, update a user profile, get a list of friends, etc.
Get a User Info
Retrieves information of a user.
Function
func getUserInfo(userId: String, completion: @escaping (CHUser?,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user. |
Request Example
ChannelizeAPIService.getUserInfo(userId: "21544", completion: {(user,errorString) in
})
Completion Handler
user
CHUser
object if api call is successful.errorString
Optional error string if there is an error.
Update User Info
Updates information of a user.
Function
func updateUserInfo(userId: String, queryBuilder: CHUserUpdateQueryBuilder, completion: @escaping (Bool,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user. |
queryBuilder | CHUserUpdateQueryBuilder | yes | Querybuilder for generating required params to filter the results. |
CHUserUpdateQueryBuilder Variables
Name | Type | Required | Description |
---|---|---|---|
displayName | String | No | Display name of the user. |
language | String | No | Specifies the code of language to translate the text phrases used in User Interface. |
profileImageUrl | String | No | The URL of user's profile image. |
metaData | [String:Any] | No | Additional information of the user like: location, gender etc. |
profileUrl | String | No | The unique URL of user's profile. |
isOnline | Bool | No | Indicates if user is online or offline. |
visibility | CHUserVisibility | No | Indicates if user is visible. Possible values are .online and .offline |
notificationOn | Bool | No | Indicates if notifications are enabled for the user. |
String | No | Updated email address of the user. |
Request Example
let queryBuilder = CHUserUpdateQueryBuilder()
queryBuilder.displayName = "Demo User"
queryBuilder.email = "demouser@channnelize.io"
queryBuilder.isOnline = true
queryBuilder.visibility = .online
queryBuilder.language = "en"
ChannelizeAPIService.updateUserInfo(userId: "21544", queryBuilder: queryBuilder, completion: {(status,errorString) in
})
Completion Handler
status
Bool value indicating the status of the result.errorString
Optional error string if api call was unsuccessful.
Delete User
Deletes a user.
Function
func deleteUser(userId: String, completion: @escaping (Bool,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user. |
Request Example
ChannelizeAPIService.deleteUser(userId: "21544", completion: {(status,errorString) in
})
Completion Handler
status
Bool value indicating the status of the result.errorString
Optional error string if there is an error.
Add a Friend / Create Connection
Channelize.io allows a user to maintain two type of relationships with another user i.e Friendship and Following. This API call allows a user to add another user as a friend or start follow him. Type of relationships supported:
- One-way friendship i.e. Follow
- Two-way friendship
Function
func addUserAsFriend(userId: String, friendshipType: FriendShipType, completion: @escaping (Bool,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user to whom logged-in user wants to send friendship or follow request. |
friendshipType | FriendShipType | No | Specifies the type of relationship request to send. Acceptable values are .oneWay and .twoWay. If set to .oneWay, the follow request will send. If set to .twoWay, friendship request will send. |
Request Example
ChannelizeAPIService.addUserAsFriend(userId: "21544", friendshipType: .twoWay, completion: {(status,errorString) in
})
Completion Handler
status
Bool value indicating the status of the result.errorString
Optional error string if there is an error.
Remove Friend / Connection
Removes a user from another user's friends list or following list.
Function
func removeUserAsFriend(userId: String, friendshipType: FriendShipType, completion: @escaping (Bool,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user to be removed from logged-in user's friends list or following list. |
friendshipType | FriendShipType | No | Specifies whether to remove the user from the Friends list or the following list. Acceptable values are .oneWay and .twoWay. If set to .oneWay, the user will be removed from following list. If set to .twoWay, the user will be removed from friends list. |
Request Example
ChannelizeAPIService.removeUserAsFriend(userId: "21544", friendshipType: .twoWay, completion: {(status,errorString) in
})
Completion Handler
status
Bool value indicating the status of the result.errorString
Optional error string if there is an error.
Get Users
Retrieves a list of users in your application. You can filter the list using various parameters.
This is an admin API. To call a admin API, please put your Channelize.io account's private key in Channelize-Info.plist
file under key as
<key>PRIVATE_KEY</key>
<string>myPrivateKey</string>
Function
func getUsersList(queryBuilder: CHUserQueryBuilder, completion: @escaping ([CHUser]?,String?) -> ())
Function Params
The following table lists the parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
queryBuilder | CHUserQueryBuilder | yes | Querybuilder for generating required params to filter the results |
CHUserQueryBuilder Variables
Name | Type | Required | Description |
---|---|---|---|
isOnline | Bool | No | Restricts the search scope to only retrieve online or offline users. If set to false, offline users are returned. If set to true, online users are returned in the response. |
searchQuery | String | No | Searches for users whose display name matches the specified value. |
sorting | CHSearchSortingType | No | Specifies the sorting criteria for the returned results. Allowed values are .ASC and displayName .DESC. |
limit | Int | No | Specifies the number of results to return. |
skip | Int | No | Specifies the number of results you want to skip from the beginning. (Useful in pagination) |
includeDeleted | Bool | No | Determines whether to include blocked users in the list. |
metaData | [String:Any] | No | Searches for users whose metaData matches the specified value. Like : "metaData.location" : "USA" |
Request Example
let queryBuilder = CHUserQueryBuilder()
queryBuilder.isOnline = true
queryBuilder.includeDeleted = false
queryBuilder.sorting = .DESC
queryBuilder.searchQuery = "Ram"
queryBuilder.limit = 30
queryBuilder.skip = 0
Completion Handler
users
[CHUser]
array containing Users.errorString
Optional error string if there is an error.
Get Friends / Connections
Retrieves a list of all friends of a user. You can pass various query parameters in this API to filter the list of friends.
Function
func getFriendsList(queryBuilder: CHFriendQueryBuilder, completion: @escaping ([CHUser]?,String?) -> ())
Function Params
The following table lists the parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
queryBuilder | CHFriendQueryBuilder | yes | Querybuilder for generating required params to filter the results |
CHFriendQueryBuilder Variables
Name | Type | Required | Description |
---|---|---|---|
isOnline | Bool | No | Restricts the search scope to only retrieve online or offline users. If set to false, offline users are returned. If set to true, online users are returned in the response. |
searchQuery | String | No | Searches for users whose display name matches the specified value. |
sorting | CHSearchSortingType | No | Specifies the sorting criteria for the returned results. Allowed values are .ASC and displayName .DESC. |
limit | Int | No | Specifies the number of results to return. |
skip | Int | No | Specifies the number of results you want to skip from the beginning. (Useful in pagination) |
skipUserIds | String | No | Specifies the user id you want to skip. If there are multiple ids append them and create a comma seperated string. For e.g "21544,21538,21678" |
includeBlocked | Bool | No | Determines whether to include blocked users in the list. |
metaData | [String:Any] | No | Searches for users whose metaData matches the specified value. Like : "metaData.location" : "USA" |
Request Example
let queryBuilder = CHUserQueryBuilder()
queryBuilder.isOnline = true
queryBuilder.includeBlocked = false
queryBuilder.sorting = .DESC
queryBuilder.searchQuery = "Ram"
queryBuilder.limit = 30
queryBuilder.skip = 0
ChannelizeAPIService.getFriendsList(queryBuilder: queryBuilder, completion: {(users,errorString) in
})
Completion Handler
users
[CHUser]
array containing friends.errorString
Optional error string if there is an error.
Get Friends / Connections Count
Retrieves the total number of users in friends or followings list of a user. You can pass various query parameters in this API to filter the result.
Function
func getFriendsListCount(queryBuilder: CHUserCountQueryBuilder, completion: @escaping (Int,String?) -> ())
Function Params
Name | Type | Required | Description |
---|---|---|---|
queryBuilder | CHUserCountQueryBuilder | yes | Querybuilder for generating required params to filter the results |
CHUserCountQueryBuilder Variables
Name | Type | Required | Description |
---|---|---|---|
isOnline | Bool | No | Restricts the search scope to only retrieve online OR offline users count. If set to false, offline users count is returned. If set to true, online users count is returned in the response. |
searchQuery | String | No | Returns the count of users whose display name matches the specified value. |
includeBlocked | Bool | No | Restricts the search scope to include the count of blocked users on the list. |
metaData | [String:Any] | No | Searches for users whose metaData matches the specified value. Like : "metaData.location" : "USA" |
Request Example
let queryBuilder = CHUserCountQueryBuilder()
queryBuilder.isOnline = true
queryBuilder.includeBlocked = false
queryBuilder.searchQuery = "Ram"
ChannelizeAPIService.getFriendsListCount(queryBuilder: queryBuilder, completion: {(count,errorString) in
})
Completion Handler
count
Count of the number of friends.errorString
Optional error string if there is an error.
Block a User
Channelize.io allows a user to block another user. Blocked users can send messages to the blocker, however, the blocker will not recieve any message from the blocked user. Also, blocking someone doesn't alert them that they have been blocked.
Function
func blockUser(userId: String, completion: @escaping (Bool,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user to block. |
Request Example
ChannelizeAPIService.blockUser(userId: "21567", completion: {(isBlocked,errorString) in
})
Completion Handler
isBlocked
Bool value indicating the status of the result.errorString
Optional error string if there is an error.
Unblock a User
Allows a user to remove another user from his blocked list.
Function
func unblockUser(userId: String, completion: @escaping (Bool,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user to unblock. |
Request Example
ChannelizeAPIService.unblockUser(userId: "21567", completion: {(isUnblocked,errorString) in
})
Completion Handler
isUnblocked
Bool value indicating the status of the result.errorString
Optional error string if there is an error.
Check Relationship Status
Allows checking your relationships status with another user.
Function
func getRelationshipStatus(userId: String, completion: @escaping (CHUserStatusModel?,String?) -> ())
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
userId | string | yes | The unique ID of the user for/with which you want to check the relationship status. |
Request Example
ChannelizeAPIService.getRelationshipStatus(userId: "21567", completion: {(statusModel,errorString) in
})
Completion Handler
statusModel
CHUserStatusModel
model.errorString
Optional error string if there is an error.
CHUserStatusModel
Variables
Name | Description |
---|---|
isBlocked | Indicates if the logged in user has blocked the given user. |
hasBlocked | Indicates if the given user has blocked the logged in user. |
hasFollowed | Indicates if the given user has followed the logged in user. |
isFollowed | Indicates if the logged in user has followed the given user. |
Get Blocked Users
Retrieves the list of all users blocked by a user.
Function
func getBlockedUsers(queryBuilder: CHUserQueryBuilder, completion: @escaping ([CHUser]?,String?) -> ())
Function Params
Name | Type | Required | Description |
---|---|---|---|
queryBuilder | CHUserQueryBuilder | yes | Querybuilder for generating required params to filter the results |
CHUserQueryBuilder Variables
Name | Type | Required | Description |
---|---|---|---|
isOnline | Bool | No | Restricts the search scope to only retrieve online or offline users. If set to false, offline users are returned. If set to true, online users are returned in the response. |
searchQuery | String | No | Searches for users whose display name matches the specified value. |
sorting | CHSearchSortingType | No | Specifies the sorting criteria for the returned results. Allowed values are .ASC and displayName .DESC. |
limit | Int | No | Specifies the number of results to return. |
skip | Int | No | Specifies the number of results you want to skip from the beginning. (Useful in pagination) |
metaData | [String:Any] | No | Searches for users whose metaData matches the specified value. Like : "metaData.location" : "USA" |
Request Example
let queryBuilder = CHUserQueryBuilder()
queryBuilder.isOnline = true
queryBuilder.sorting = .DESC
queryBuilder.searchQuery = "Demo"
queryBuilder.limit = 30
queryBuilder.skip = 0
ChannelizeAPIService.getBlockedUsers(queryBuilder: queryBuilder, completion: {(blockedUsers,errorString) in
})
Completion Handler
blockedUsers
[CHUser]
array containing blocked users.errorString
Optional error string if there is an error.
Get Blocked Users Count
Retrieves the total number of users in the blocked list of a user. You can pass various query parameters in this API to filter the result.
Function
func getBlockedUsersCount(queryBuilder: CHUserCountQueryBuilder, completion: @escaping (Int,String?) -> ())
Function Params
Name | Type | Required | Description |
---|---|---|---|
queryBuilder | CHUserCountQueryBuilder | yes | Querybuilder for generating required params to filter the results |
CHUserCountQueryBuilder Variables
Name | Type | Required | Description |
---|---|---|---|
isOnline | Bool | No | Restricts the search scope to only retrieve online OR offline users count. If set to false, offline users count is returned. If set to true, online users count is returned in the response. |
searchQuery | String | No | Returns the count of users whose display name matches the specified value. |
metaData | [String:Any] | No | Searches for users whose metaData matches the specified value. Like : "metaData.location" : "USA" |
Request Example
let queryBuilder = CHUserCountQueryBuilder()
queryBuilder.isOnline = true
queryBuilder.searchQuery = "Demo"
ChannelizeAPIService.getBlockedUsersCount(queryBuilder: queryBuilder, completion: {(count,errorString) in
})
Completion Handler
count
Count of the blocked users.errorString
Optional error string if there is an error.