# User

## Set user display name

```objectivec
- (MXHTTPOperation*)setDisplayName:(NSString*)displayname
                           success:(void (^)(void))success
                           failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**:：

<table><thead><tr><th width="174">Name</th><th width="114">Type</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td><code>displayname</code></td><td>NSString</td><td>the new display name</td><td>true</td></tr></tbody></table>

**Output Parameters**：

<table><thead><tr><th width="126">Name</th><th align="center">Type</th><th width="255">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td align="center">A block object</td><td>A block object called when the operation succeeds.</td><td>true</td></tr><tr><td>failure</td><td align="center">A block object</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Get the display name of a user

```objectivec
- (MXHTTPOperation*)profileForUser:(NSString*)userId
                           success:(void (^)(NSString *displayName, NSString *avatarUrl))success
                           failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**:：

| Name   | Type   | Description | Required |
| ------ | ------ | ----------- | -------- |
| userId | string | the user ID | True     |

**Output Parameters**：

<table><thead><tr><th>Name</th><th width="133">Type</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>displayName</td><td>NSString</td><td>user display name</td><td>true</td></tr><tr><td>avatarUrl</td><td>NSString</td><td>url of the profile image</td><td>true</td></tr></tbody></table>

## Set user avatar

Set the user's profile image url. The user must have previously logged into SendingNetwork.

```objectivec
- (MXHTTPOperation*)setAvatarUrl:(NSString*)avatarUrl
                         success:(void (^)(void))success
                         failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**:：

| Name        | Type     | Description        | Required |
| ----------- | -------- | ------------------ | -------- |
| `avatarUrl` | NSString | the new avatar url | True     |

**Output Parameters**：

<table><thead><tr><th width="108">Name</th><th width="143">Type</th><th width="388">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>A block object</td><td>A block object called when the operation succeeds</td><td>true</td></tr><tr><td>failure</td><td>A block object</td><td>A block object called when the operation fails</td><td>true</td></tr></tbody></table>

## Get the avatar url of a user

```objectivec
- (MXHTTPOperation*)avatarUrlForUser:(NSString*)userId
                             success:(void (^)(NSString *avatarUrl))success
                             failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;

```

**Input Parameters**:：

| Name     | Type     | Description | Required |
| -------- | -------- | ----------- | -------- |
| `userId` | NSString | the user ID | True     |

**Output Parameters**：

| Name    | Type  | Description                                                                         | Required |
| ------- | ----- | ----------------------------------------------------------------------------------- | -------- |
| success | block | A block object called when the operation succeeds. It provides the user avatar url. | true     |
| failure | block | A block object called when the operation fails.                                     | true     |

## Get the profile information of a user

```objectivec
- (MXHTTPOperation*)profileForUser:(NSString*)userId
                           success:(void (^)(NSString *displayName, NSString *avatarUrl))success
                           failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT;
```

**Input Parameters**:：

| Name     | Type     | Description | Required |
| -------- | -------- | ----------- | -------- |
| `userId` | NSString | the user id | True     |

**Output Parameters**：

<table><thead><tr><th width="123">Name</th><th width="111">Type</th><th width="418">Description</th><th>Required</th></tr></thead><tbody><tr><td>success</td><td>NSString</td><td>A block object called when the operation succeeds. It provides the user display name and avatar url.</td><td>true</td></tr><tr><td>failure</td><td>NSString</td><td>A block object called when the operation fails.</td><td>true</td></tr></tbody></table>

## Set signature for a user

```objectivec
- (MXHTTPOperation*)setSignatureWithUserId:(NSString *)userId
                                 signature:(NSString *)signature
                                   success:(void (^)(void))success
                                   failure:(void (^)(NSError *error))failure
```

**Input Parameters**:：

| Name      | Type     | Description              | Required |
| --------- | -------- | ------------------------ | -------- |
| `userId`  | NSString | user ID                  | True     |
| signature | NSString | signature, length <= 100 | True     |

**Output Parameters**：

| Name    | Type  | Description         | Required |
| ------- | ----- | ------------------- | -------- |
| success | block | success description | true     |
| failure | block | failure description | true     |

## Get signature of a user

```objectivec
- (MXHTTPOperation*)getSignatureWithUserId:(NSString *)userId
                                   success:(void (^)(NSString * signature))success
                                   failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:：

| Name     | Type     | Description | Required |
| -------- | -------- | ----------- | -------- |
| `userId` | NSString | the user id | True     |

**Output Parameters**：

| Name    | Type  | Description                                  | Required |
| ------- | ----- | -------------------------------------------- | -------- |
| success | block | (**void** (^)(NSString \* signature))success | true     |
| failure | block | failure description                          | true     |

***

{% hint style="warning" %}
The APIs below are deprecated. Please avoid using them.
{% endhint %}

## **(Deprecated) Modify nickname**

```swift
client?.setDisplayName(displayName, completion: { response in })
```

**Input Parameters**：

| Name          | Type   | Description   | Required |
| ------------- | ------ | ------------- | -------- |
| `displayName` | string | new nick name | true     |

## **(Deprecated) Modify profile image**

```swift
client?.setAvatarUrl(URL.init(string: avatarUrl), completion: { response in })
```

**Input Parameters**：

| Name        | Type   | Description           | Required |
| ----------- | ------ | --------------------- | -------- |
| `avatarUrl` | string | new profile image URL | true     |

## **(Deprecated) Query profile information**

```swift
client?.profile(forUser: user_id, completion: { response in })
```

**Input Parameters**：

| Name      | Type   | Description | Required |
| --------- | ------ | ----------- | -------- |
| `user_id` | string | user id     | true     |

**Output Parameters**：

| Name          | Type   | Description                   |
| ------------- | ------ | ----------------------------- |
| `displayname` | string | user nickname string          |
| `avatar_url`  | String | user profile image URL string |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sending-network.gitbook.io/sending.network/sdk-documentation/ios-client-sdk/user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
