Manage user details

Get details about the app users.

Get user details

Return data about a specific user with the getUser() method.

By default, this method returns all custom user metadata without the need to define that during the call explicitly.

Requires App Context

To store data about users, you must enable App Context for your app's keyset in the Admin Portal.

Method signature

This method takes the following parameters:

chat.getUser(
userId: String,
completion: ((Swift.Result<UserImpl?, Error>) -> Void)? = ni
)

Input

ParameterTypeRequiredDefaultDescription
userIdStringYesn/aUnique user identifier (up to 92 UTF-8 characters).

Output

TypeDescription
UserImplReturned object containing the user metadata.

Basic usage

Get details on user support_agent_15.

/// Assuming you have a "chat" instance available
/// Invoke the "getUser" method to fetch metadata of the 'support_agent_15'
chat.getUser(
userId: "support_agent_15"
) {
switch $0 {
case let .success(user):
if let user = user {
debugPrint("Fetched user metadata with ID: \(user.id)")
} else {
debugPrint("User not found")
}
case let .failure(error):
debugPrint("Failed to fetch user metadata: \(error)")
}
show all 16 lines

Get current user

You can access the currentUser property of the Chat object to get the current chat user of the chat app.

Requires App Context

To store data about users, you must enable App Context for your app's keyset in the Admin Portal.

Basic usage

Return the current chat user.

/// Assuming you have a "chat" instance available
/// Access the "currentUser" property to get details of the current chat user
let currentUser = chat.currentUser
Last updated on