Users
This section contains the User operations that can be performed using Android API SDK i.e Add/remove friends or following, block user, unblock user, update a user profile, get a list of friends/followers, etc.
Get User
Retrieves information of a user using this method.
* @param USER_ID (Required, String): The unique ID of the user.
channelizeApi.getUser(USER_ID, new CompletionHandler<User>() {
@Override
public void onComplete(User user, ChannelizeError error) {
}
});
Add a Friend
This method allows a user to add another user to his friends list.
* @param USER_ID (Required, String): The unique Id of the user whom you want to add as friend.
channelizeApi.addFriend(USER_ID, new CompletionHandler<RequestResponse>() {
@Override
public void onComplete(RequestResponse response, ChannelizeError error) {
}
});
Remove friend
This method allows a user to remove another user from his friends list.
* @param USER_ID (Required, String): The unique Id of the user whom you want to remove from friends list.
channelizeApi.removeFriend(USER_ID, new CompletionHandler<RequestResponse>() {
@Override
public void onComplete(RequestResponse response, ChannelizeError error) {
}
});
Block/Unblock a User
This method let 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.
* @param USER_ID (Required, String): The unique ID of the user to block.
channelizeApi.blockUser(USER_ID, new CompletionHandler<RequestResponse>() {
@Override
public void onComplete(RequestResponse response, ChannelizeError error) {
}
});
You can unblock a user with the following code:
* @param USER_ID (Required, String): The unique ID of the user to unblock.
channelizeApi.unBlockUser(USER_ID, new CompletionHandler<RequestResponse>() {
@Override
public void onComplete(RequestResponse response, ChannelizeError error) {
}
});
Get Friends
Retrieves a list of all friends of the logged-in user.
* @param userQuery Query for filtering the results.
UserQuery userQuery = new UserQuery.Builder()
.isOnline(true) // 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.
.setSearchQuery(QUERY) // Searches for users whose display name matches the specified value.
.includeBlocked(true) // Determines whether to include blocked users in the response list.
.setSorting(UserQuery.SORT_ASCENDING) // Specifies the sorting criteria for the returned results.
.setLimit(20) // Specifies the number of results to return in single request.
.setOffset(0) // Specifies the number of results you want to skip from the beginning. (Useful in pagination)
.skipUsers("1,2,3") // Specifies the unique IDs of the users you want to skip from the response. (Comma separated string).
.build();
channelizeApi.getFriendsList(userQuery, new CompletionHandler<ListUserResponse>() {
@Override
public void onComplete(ListUserResponse result, ChannelizeError error) {
if (result != null) {
List<User> userList = result.getUsers();
}
}
});
Get Friends Count
Retrieves the total number of users in friends list.
* @param userQuery Query for filtering the results.
UserQuery userQuery = new UserQuery.Builder()
.isOnline(true) // 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.
.setSearchQuery(QUERY) // Searches for users whose display name matches the specified value.
.includeBlocked(true) // Determines whether to include blocked users in the response list.
.build();
channelizeApi.getFriendsCount(userQuery, new CompletionHandler<TotalCountResponse>() {
@Override
public void onComplete(TotalCountResponse result, ChannelizeError error) {
int count = result.getCount();
}
});
Get Blocked Users
Retrieves the list of all blocked users.
* @param userQuery Query for filtering the results.
UserQuery userQuery = new UserQuery.Builder()
.isOnline(true) // 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.
.setSearchQuery(QUERY) // Searches for users whose display name matches the specified value.
.setSorting(UserQuery.SORT_ASCENDING) // Specifies the sorting criteria for the returned results.
.setLimit(20) // Specifies the number of results to return in a single request.
.setOffset(0) // Specifies the number of results you want to skip from the beginning. (Useful in pagination)
.build();
channelizeApi.getBlockedUsersList(userQuery, new CompletionHandler<ListUserResponse>() {
@Override
public void onComplete(ListUserResponse result, ChannelizeError error) {
if (result != null) {
List<User> userList = result.getUsers();
}
}
});
Get Blocked Users Count
Retrieves the total number of users in the blocked list.
* @param userQuery Query for filtering the results.
UserQuery userQuery = new UserQuery.Builder()
.isOnline(true) // 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.
.setSearchQuery(QUERY) // Searches for users whose display name matches the specified value.
.build();
channelizeApi.getBlocksCount(userQuery, new CompletionHandler<TotalCountResponse>() {
@Override
public void onComplete(TotalCountResponse result, ChannelizeError error) {
int count = result.getCount();
}
});
Check block status
Allows checking block status b/w a user and the logged-in user.
* @param USER_ID (Required, String): The unique ID of the user with which you want to check the blocked status.
channelizeApi.checkBlockStatus(USER_ID, new CompletionHandler<UserBlockStatusResponse>() {
@Override
public void onComplete(UserBlockStatusResponse response, ChannelizeError error) {
}
});
Go Online
Updates the status of a user to online.
channelizeApi.setUserOnline(new CompletionHandler<User>() {
@Override
public void onComplete(User user, ChannelizeError error) {
}
});
Go Offline
Updates the status of a user to offline.
channelizeApi.setUserOffline(new CompletionHandler<User>() {
@Override
public void onComplete(User user, ChannelizeError error) {
}
});
Update User Info
Updates information of a user.
* @param userQuery Query for adding param into request.
UserQuery userQuery = new UserQuery.Builder()
.setTitle(USER_TITLE) // The user's name.
.setProfileImageUrl("") // The URL of user's profile image.
.setNotification(true) // Updates notifications setting for a user. Set true, if you want to enable notifications. Set false, if you want to disable the notifications.
.setVisibility(true) // Updates visibility setting for a user. Set true, if you want to enable visibility. Set false, if you want to disable visibility.
.build();
channelizeApi.updateUserInfo(userQuery, new CompletionHandler<User>() {
@Override
public void onComplete(User user, ChannelizeError error) {
}
});