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:
1chat.getUser(userId: String): PNFuture<User?>
Input
*  required
| Parameter | Description | 
|---|---|
| userId*Type:  StringDefault: n/a | Unique user identifier (up to 92 UTF-8 characters). | 
Output
| Type | Description | 
|---|---|
| PNFuture<User?> | PNFuturecontaining the user object with its metadata. | 
Sample code
Get details on user support_agent_15.
1// reference the "chat" object and invoke the "getUser()" method
2chat.getUser("support_agent_15").async { result ->
3result.onSuccess {
4        // handle success
5    }.onFailure {
6        // handle failure
7    }
8}
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.
Sample code
Return the current chat user.
1try {
2    Result.success(chat.currentUser)
3}.onSuccess { user ->
4    user?.let {
5        println("Current user is ${it.name} with ID ${it.id}")
6    } ?: run {
7        println("No current user in chat")
8    }
9}.onFailure { exception ->
10    println("Failed to retrieve current user: ${exception.message}")
11}