# Contact

## Get contact list

```objectivec
- (MXHTTPOperation*)getContactsListWithUserId:(NSString *)userId
                                      success:(void (^)(MXContactsListResponse *contactsListResponse))success
                                      failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:

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

**Output Parameters**

`MXContactsListResponse`

## Add user as a contact

```objectivec
- (MXHTTPOperation*)addToFavoritesWithUserId:(NSString *)userId
                                   contactId:(NSString *)contactId
                                        tags:(NSArray*)tags
                                     isRoom:(BOOL)isRoom
                                     success:(void (^)(void))success
                                     failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:

| Name      | Type     | Description                 | Required |
| --------- | -------- | --------------------------- | -------- |
| userId    | NSString | user id string              | true     |
| contactId | NSString | contact id string           | true     |
| tags      | NSArray  | tags NSArray                | false    |
| isRoom    | bool     | whether is a direct message | true     |

## Remove contact

```objectivec
- (MXHTTPOperation*)deleteFavoritesWithUserId:(NSString *)userId
                                   contactId:(NSString *)contactId
                                     isRoom:(BOOL)isRoom
                                     success:(void (^)(void))success
                                      failure:(void (^)(NSError *error))failure;
```

**Input Parameters**:

| Name      | Type     | Description                 | Required |
| --------- | -------- | --------------------------- | -------- |
| userId    | NSString | user id string              | true     |
| contactId | NSString | contact id string           | True     |
| isRoom    | BOOL     | whether is a direct message | True     |

**Output Parameters**：

| Name    | Type  | Description                                       | Required |
| ------- | ----- | ------------------------------------------------- | -------- |
| success | block | A block object called when the operation succeeds | true     |
| failure | block | A block object called when the operation fails.   | true     |

***

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

## (Deprecated) Get contact list

```swift
client?.getContactsList(withUserId: user_id, success: { <#MXContactsListResponse?#> in }, failure: <#T##((Error?) -> Void)!##((Error?) -> Void)!##(Error?) -> Void#>)
```

Parameters:

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

Returns

`MXContactsListResponse`

## (Deprecated) Add user as a contact

```swift
client?.addToFavorites(withUserId: user_id, contactId: contactId, isRoom: true, success: {}, failure: { error in })
```

Parameters:

| Name        | Type   | Description                 | Required |
| ----------- | ------ | --------------------------- | -------- |
| `user_id`   | string | user id string              | true     |
| `contactId` | string | contact id string           | true     |
| `isRoom`    | bool   | whether is a direct message | true     |

## (Deprecated) Remove contact

```swift
client?.deleteFavorites(withUserId: user_id, contactId: contactId, isRoom: true, success: {}, failure: { error in })
```

Parameters:

| Name        | Type   | Description                 | Required |
| ----------- | ------ | --------------------------- | -------- |
| `user_id`   | string | user id string              | true     |
| `contactId` | string | contact id string           | True     |
| `isRoom`    | bool   | whether is a direct message | True     |


---

# 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/contact.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.
