> For the complete documentation index, see [llms.txt](https://docs.taptalk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md).

# Contact

If your application is using the core implementation type, you can use these methods to manage your user's contacts.

| **TapTalk Contact Method**                                                                                                                                                     | **Description**                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| [Get Contact List](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#get-contact-list)                                                         | Get all of the user's contact data from TapTalk.io.                               |
| [Fetch All User Contacts from Server](#fetch-all-user-contacts-from-server)                                                                                                    | Fetch the user's latest contact data from TapTalk.io server                       |
| [Get Contact Detail Info with TapTalk User ID](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#get-contact-detail-info-with-taptalk-user-id) | Get a detailed contact info with selected TapTalk.io user ID.                     |
| [Get Contact Detail Info with Client User ID](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#get-contact-detail-info-with-client-user-id)   | Get a detailed contact info with selected Client user ID (xcUserID).              |
| [Add User to Contact with User ID](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#add-user-to-contact-with-user-id)                         | Add a user with selected TapTalk.io user ID to the active user's contacts.        |
| [Add User to Contact with Phone Number](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#add-user-to-contact-with-phone-number)               | Add a user with selected phone number to the active user's contacts.              |
| [Remove User from Contact](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#remove-user-from-contact)                                         | Remove a user with selected TapTalk.io user ID from the active user's contacts.   |
| [Save User Data](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/contact.md#save-user-data)                                                             | Save or update existing user data to local cache.                                 |
| [Search Local Contact](#search-local-contact)                                                                                                                                  | Search the active user's contacts from the device's local storage with a keyword. |
| [Report User](#report-user)                                                                                                                                                    | Submit a report for a selected user.                                              |
| [Report Message](#report-message)                                                                                                                                              | Submit a report for a selected message.                                           |
| [Block User](#block-user)                                                                                                                                                      | Block a user from sending or receiving messages.                                  |
| [Unblock User](#unblock-user)                                                                                                                                                  | Unblock a blocked user.                                                           |
| [Get Blocked User List](#get-blocked-user-list)                                                                                                                                | Retrieve a list of blocked users.                                                 |
| [Get Blocked User IDs](#get-blocked-user-ids)                                                                                                                                  | Retrieve a list of IDs from blocked users.                                        |
| [Get Groups in Common](#get-groups-in-common)                                                                                                                                  | Retrieve the list of groups in common with another user.                          |

### Get Contact List

Create a new group Get all of the user's contact data from TapTalk.io.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] getAllUserContactsWithSuccess:^(NSArray<TAPUserModel *> * _Nonnull userArray) {
    // Successfully fetched contact list data
}
failure:^(NSError * _Nonnull error) {
    // Failed to get contact list data
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().getAllUserContacts { userArray in
    // Successfully fetched contact list data
}
failure: { error in
    // Failed to get contact list data
}
```

{% endtab %}
{% endtabs %}

### Fetch All User Contacts from Server

Calling `fetchAllUserContactsFromServer` will fetch the user's latest contact data from TapTalk.io server and syncs it to the device's local storage.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] fetchAllUserContactsFromServerWithSuccess:^(NSArray<TAPUserModel *> * _Nonnull userArray) {
    // Successfully fetched contact list data
}
failure:^(NSError * _Nonnull error) {
    // Failed to get contact list data
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().fetchAllUserContactsFromServer { userArray in
    // Successfully fetched contact list data
}
failure: { error in
    // Failed to get contact list data
}
```

{% endtab %}
{% endtabs %}

### Get Contact Detail Info with TapTalk User ID

Get a detailed contact info with selected TapTalk.io user ID.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] getUserDataWithUserID:USER_ID
success:^(TAPUserModel * _Nonnull user) {
    // Successfully obtained contact details
}
failure:^(NSError * _Nonnull error) {
    // Failed to get contact details
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().getUserData(withUserID: USER_ID) { user in
    // Successfully obtained contact details
}
failure: { error in
    // Failed to get contact details
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) Taptalk.io User ID of the selected user
{% endhint %}

### Get Contact Detail Info with Client User ID

Get a detailed contact info with selected Client user ID (xcUserID).

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] getUserDataWithXCUserID:XC_USER_ID
success:^(TAPUserModel * _Nonnull user) {
    // Successfully obtained contact details
}
failure:^(NSError * _Nonnull error) {
    // Failed to get contact details
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().getUserData(withXCUserID: XC_USER_ID) { user in
    // Successfully obtained contact details
}
failure: { error in
    // Failed to get contact details
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`XC_USER_ID`**: (String) Client User ID of the selected user
{% endhint %}

### Add User to Contacts with User ID

Add a user with selected TapTalk.io user ID to the active user's contacts.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] addToTapTalkContactsWithUserID:USER_ID
success:^{
    // Successfully added contact
}
failure:^(NSError * _Nonnull error) {
    // Failed to add contact
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().addToTapTalkContacts(withUserID: USER_ID) {
    // Successfully added contact
}
failure: { error in
    // Failed to add contact
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) Taptalk.io User ID of the contact to be added
{% endhint %}

### Add User to Contacts with Phone Number

Add a user with selected phone number to the active user's contacts.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] addToTapTalkContactsWithPhoneNumber:PHONE_NUMBER
success:^{
    // Successfully added contact
}
failure:^(NSError * _Nonnull error) {
    // Failed to add contact
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().addToTapTalkContacts(withPhoneNumber: PHONE_NUMBER) {
    // Successfully added contact
}
failure: { error in
    // Failed to add contact
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`PHONE_NUMBER`**: (String) phone number of the contact to be added
{% endhint %}

### Remove User from Contacts

Remove a user with selected TapTalk.io user ID from the active user's contacts.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] removeFromTapTalkContactsWithUserID:USER_ID
success:^(NSString * _Nonnull successMessage) {
    // Successfully removed contact
}
failure:^(NSError * _Nonnull error) {
    // Failed to remove contact
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().removeFromTapTalkContacts(withUserID: USER_ID) { successMessage in
    // Successfully removed contact
}
failure: { error in
    // Failed to remove contact
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) Taptalk.io User ID of the contact to remove.
{% endhint %}

### Save User Data

Save or update existing user data to local cache.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] saveUserData:USER];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().saveUserData(USER)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER`**: (TAPUserModel) the user data model to be saved
{% endhint %}

### Search Local Contact

Call this method to search the active user's contacts from the device's local storage with a keyword. Provided keyword will be used to filter the contacts' **full name** in the search result.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] searchLocalContactsByName:KEYWORD
success:^(NSArray<TAPUserModel *> * _Nonnull userArray) {
    // Returns filtered contacts
}
failure:^(NSError * _Nonnull error) {
    // Failed to get contact list data
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().searchLocalContacts(byName: KEYWORD) { userArray in
    // Returns filtered contacts
}
failure: { error in
    // Failed to get contact list data
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`KEYWORD`**: (String) search keyword to filter full name
{% endhint %}

### Report User

You may call this method to submit a report for a selected user. Submitted reports can then be viewed through the dashboard.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] reportUser:USER_ID 
                                         category:CATEGORY
                                  isOtherCategory:IS_OTHER_CATEGORY
                                           reason:REASON
success:^(BOOL isSuccess) {
    // Successfully reported user
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().reportUser(
    USER_ID,
    category: CATEGORY,
    isOtherCategory: IS_OTHER_CATEGORY,
    reason: REASON
) { isSuccess in
    // Successfully reported user
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) ID of the user to report\
**`CATEGORY`**: (String) Category of the violation. max length is 100 characters\
**`IS_OTHER_CATEGORY`**: (Boolean) If the category is other than the predefined categories\
**`REASON`**: (String) reason why the user is reported
{% endhint %}

### Report Message

You may call this method to submit a report for a selected message. Submitted reports can then be viewed through the dashboard.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] reportMessage:MESSAGE_ID 
                                              roomID:ROOM_ID
                                            category:CATEGORY
                                     isOtherCategory:IS_OTHER_CATEGORY
                                              reason:REASON
success:^(BOOL isSuccess) {
    // Successfully reported message
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().reportMessage(
    MESSAGE_ID,
    category: CATEGORY,
    isOtherCategory: IS_OTHER_CATEGORY,
    reason: REASON
) { isSuccess in
    // Successfully reported message
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`MESSAGE_ID`**: (String) unique server ID of the message to report\
**`ROOM_ID`**: (String) ID of the room where the message belongs to\
**`CATEGORY`**: (String) Category of the violation. max length is 100 characters\
**`IS_OTHER_CATEGORY`**: (Boolean) If the category is other than the predefined categories\
**`REASON`**: (String) reason why the message is reported
{% endhint %}

### Block User

You may block a user to stop conversation flow with the blocked user. Blocked users will not be able to send and receive message, or retrieve profile info from the active user.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] blockUserWithUserID:USER_ID 
success:^(TAPUserModel *blockedUser) {
    // Successfully blocked user
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().blockUser(withUserID: USER_ID) { blockedUser in
    // Successfully blocked user
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) ID of the user to block
{% endhint %}

### Unblock User

You may unblock a blocked user to let them send and receive message from the active user.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] unblockUserWithUserID:USER_ID 
success:^(TAPUserModel *unblockedUser) {
    // Successfully unblocked user
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().unblockUser(withUserID: USER_ID) { unblockedUser in
    // Successfully unblocked user
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) ID of the user to unblock
{% endhint %}

### Get Blocked User List

You may call this method to retrieve a list of blocked users.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] getBlockedUserList:^(NSArray<TAPUserModel *> *blockedUserList) {
    // Successfully retrieved blocked users
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().getBlockedUserList { blockedUserList in
    // Successfully retrieved blocked users
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

### Get Blocked User IDs

You may call this method to retrieve a list of IDs from blocked users.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] getBlockedUserIDs:^(NSArray<NSString *> *blockedUserIDs) {
    // Successfully retrieved blocked user IDs
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().getBlockedUserIDs { blockedUserIDs in
    // Successfully retrieved blocked user IDs
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

### Get Groups in Common

You may use **`getGroupsInCommon`** method to retrieve the list of groups in common with another user.

{% tabs %}
{% tab title="Objective-C" %}

```objective-c
// For version 3.0.0 and above
#import "PowerTalk.h"

// For versions below 3.0.0
#import <TapTalk/TapCoreContactManager.h>

[[TAPCoreContactManager sharedManager] getGroupsInCommon:USER_ID 
success:^(NSArray<TAPRoomModel *> *groupRooms) {
    // Successfully retrieved rooms
}
failure:^(NSError * _Nonnull error) {

}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
import PowerTalk

TAPCoreContactManager.shared().getGroupsInCommon(USER_ID) { groupRooms in
    // Successfully retrieved rooms
}
failure: { error in
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
**`USER_ID`**: (String) ID of the other user
{% endhint %}
