User

This guide will explain the various actions which can be taken by currently logged in user of the application.

You can update various details of current user like User Avatar, User Display Name, User Profile URL etc.

Updating User Display Name

cc.updateUserDisplayName(DISPLAY_NAME, function(error, user){
	if(error == null){
  	console.log("Display Name updated successfully")
  }
})

Updating User Avatar

Updating user avatar through an external URL

cc.updateUserAvatarUrl(AVATAR_URL, function(error, user){
	if(error == null){
  	console.log("Avatar updated successfully")
  }
})

You can also update the avatar by uploading an image directly to ChatCamp Cloud.

cc.uploadUserAvatar(AVATAR_FILE, function(bytesSent, bytesTotal), function(error, user){
	if(error == null){
  	console.log("Avatar Uploaded Successfully")
  }
})

Updating User Profile URL

cc.updateUserProfileUrl(PROFILE_URL, function(error, user){
	if(error == null){
  	console.log("Profile URL updated successfully")
  }
})

Updating User MetaData

cc.updateUserMetadata(METADATA, function(error, user){
	if(error == null){
  	console.log("User Metadata updated successfully")
  }
})

Updating User Data

cc.updateUserData(DATA, function(error, user){
	if(error == null){
  	console.log("User Data updated successfully")
  }
})

Fetching Users of the application

let userListQuery = cc.createUserListQuery()
userListQuery.setLimit(LIMIT);
userListQuery.setReference(REFERENCE);
userListQuery.load(function(error, userList){
	if(error == null){
  	console.log("User List loaded successfully")
  }
})

Fetching Online Users of the application

let userListQuery = cc.createUserListQuery()
userListQuery.setLimit(LIMIT);
userListQuery.setReference(REFERENCE);
userListQuery.isOnlineFilter = "ONLINE"
userListQuery.load(function(error, userList){
	if(error == null){
  	console.log("Online User List loaded successfully")
  }
})

Block a user

blockUser(USER_ID, function(error, user){
	if(error == null){
  	console.log("User blocked successfully")
  }
})

Unblock a user

unblockUser(USER_ID, function(error, user){
	if(error == null){
  	console.log("User unblocked successfully")
  }
})

Fetching blocked users

let blockedUserListQuery = cc.createBlockedUserListQuery()
blockedUserListQuery.setLimit(LIMIT);
blockedUserListQuery.setReference(REFERENCE);
blockedUserListQuery.load(function(error, blockedUserList){
	if(error == null){
  	console.log("Blocked User List loaded successfully")
  }
})