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

CCPClient.updateDisplayNameOnServer(displayName: USER_NAME){ (user, error) in
  if error == nil {
    //"Display Name updated successfully"
  }
}

Updating User Avatar

Updating user avatar through an external URL

CCPClient.updateAvatarUrlOnServer(avatarUrl: AVATAR_URL){ (user, error) in
  if error == nil {
    //"Avatar URL updated successfully"
  }
}

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

CCPClient.shared().uploadUserAvatar(file: FILE, uploadProgressHandler: { (totalBytesSent, totalBytesExpectedToSend) in
  // code
}) (user, error) in
  if error == nil {
    //"Avatar upload successful"
  }
}

Updating User Profile URL

CCPClient.updateProfileUrlOnServer(profileUrl: PROFILE_URL){ (user, error) in
  if error == nil {
    //"Profile URL updated successfully"
  }
}

Updating User MetaData

CCPClient.updateMetadataOnServer(metadata: METADATA){ (user, error) in
  if error == nil {
    //"Metadata updated successfully"
  }
}

Updating User Data

CCPClient.updateUserData(data: DATA){ (user, error) in
  if error == nil {
   //"Data updated successfully"
  }
}

Fetching Users of the application

var usersQuery: CCPUserListQuery!
usersQuery = CCPClient.createUserListQuery()
usersQuery.load(limit: limit) {(userList, error) in
	//"User List loaded successfully"
}

Fetching Online Users of the application

var usersQuery: CCPUserListQuery!
usersQuery = CCPClient.createUserListQuery()
usersQuery.isOnlineFilter = "ONLINE"
usersQuery.load(limit: limit) {(userList, error) in
	//"User List loaded successfully"
}

Block a user

CCPClient.blockUser(userId: USER_ID){ (user, error) in
  if error == nil {
    //"User blocked successfully"
  }
}

Unblock a user

CCPClient.unblockUser(userId: USER_ID){ (user, error) in
  if error == nil {
    //"User unblocked successfully"
  }
}

Fetching blocked users

var blockedUsersQuery: CCPUserListQuery!
blockedUsersQuery = CCPClient.createBlockedUserListQuery()
blockedUsersQuery.load(limit: limit) {(blockedUserList, error) in
	//"Blocked User List loaded successfully"
}