# Chat Room and Messages - TapUI

You can use these methods when implementing your app with TapUI to open a chat room when UI implementation type is used.

| **TapTalk UI Chat Room Method**                                                                                                                                                                       | **Description**                                                                                                                         |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| [Create Personal Chat Room with User Model](#create-chat-room-with-user-model)                                                                                                                        | Creates room with user model. This method will return `TapUIChatViewController` on success.                                             |
| [Create Personal Chat Room with TapTalk.io User ID](#create-chat-room-with-taptalk.io-user-id)                                                                                                        | Creates room with TapTalk.io user ID. This method will return `TapUIChatViewController` on success.                                     |
| [Create Personal Chat Room with Client User ID](#create-chat-room-with-client-user-id)                                                                                                                | Creates room with client user ID. This method will return `TapUIChatViewController` on success.                                         |
| [Create Room with Room Model](/powertalk-chat-sdk-documentation/powertalk-ios/group-chat/group-chat-tapui.md#create-room-with-room-model)                                                             | Creates room with room model. This method will return `TapUIChatViewController` on success.                                             |
| [Create Room with Room Model & Scroll to Selected Message](/powertalk-chat-sdk-documentation/powertalk-ios/group-chat/group-chat-tapui.md#create-room-with-room-model-and-scroll-to-selected-message) | Creates room with room model. This method will return `TapUIChatViewController` on success and scroll the view to the selected message. |
| [Create Saved Messages Chat Room](#create-saved-messages-chat-room)                                                                                                                                   | Creates the active user's Saved Messages chat room. This method will return `TapUIChatViewController` on success.                       |

{% hint style="info" %}
**Note:** You can get TapTalk.io current view controller or navigation controller to integrate to your current view controller by using [getCurrentTapTalkActiveViewController](/powertalk-chat-sdk-documentation/powertalk-ios/general.md#obtain-current-navigation-controller-in-tapui) method.
{% endhint %}

### Create Personal Chat Room with User Model

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

```csharp
#import <TapTalk/TapUI.h>

[TapUI sharedInstance] createRoomWithOtherUser:OTHER_USER success:^[(TapUIChatViewController * _Nonnull chatViewController) {
   // You can choose to present or push view controller
   
   // Present room list view
   [self presentViewController:chatViewController animated:YES completion:^{
        // Completion
   }];

   // Push room list view
   [self.navigationController pushViewController:chatViewController animated:YES];
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`OTHER_USER`**: (TAPUserModel) recipient user model that will be shown
{% endhint %}

### Create Personal Chat Room with TapTalk.io User ID

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

```csharp
#import <TapTalk/TapUI.h>

[[TapUI sharedInstance] createRoomWithUserID:USER_ID
                               prefilledText:PREFILLED_TEXT
                            customQuoteTitle:CUSTOM_QUOTE_TITLE
                          customQuoteContent:CUSTOM_QUOTE_CONTENT
                   customQuoteImageURLString:CUSTOM_QUOTE_IMAGE_URL_STRING
                                    userInfo:USER_INFO
success:^(TapUIChatViewController * _Nonnull chatViewController) {
    // Successfully created chat room
    // You can choose to present or push view controller
    
    // Present room list view
    [self presentViewController:chatViewController animated:YES completion:^{
        // Completion    
    }];

    // Push room list view
    [self.navigationController pushViewController:chatViewController animated:YES];
}
failure:^(NSError * _Nonnull error) {
    // Failed open room
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`USER_ID`**: (String) TapTalk.io user ID\
\&#xNAN;**`PREFILLED_TEXT`**: (String) prefilled text of message\
\&#xNAN;**`CUSTOM_QUOTE_TITLE`**: (String) title of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_CONTENT`**: (String) content / subtitle of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_IMAGE_URL_STRING`**: (String) image url string of custom quote image\
\&#xNAN;**`USER_INFO`**: (String) client-specified data or details of the custom quote
{% endhint %}

### Create Personal Chat Room with Client User ID

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

```csharp
#import <TapTalk/TapUI.h>

[[TapUI sharedInstance] createRoomWithXCUserID:XC_USER_ID
                                 prefilledText:PREFILLED_TEXT
                              customQuoteTitle:CUSTOM_QUOTE_TITLE
                            customQuoteContent:CUSTOM_QUOTE_CONTENT
                     customQuoteImageURLString:CUSTOM_QUOTE_IMAGE_URL_STRING
                                      userInfo:USER_INFO
success:^(TapUIChatViewController * _Nonnull chatViewController) {
    // Successfully created chat room
    // You can choose to present or push view controller
    
    // Present room list view
    [self presentViewController:chatViewController animated:YES completion:^{
        // Completion
    }];

    // Push room list view
    [self.navigationController pushViewController:chatViewController animated:YES];
  
}
failure:^(NSError * _Nonnull error) {
    // Failed open room
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`XC_USER_ID`**: (String) client user ID\
\&#xNAN;**`PREFILLED_TEXT`**: (String) prefilled text of message\
\&#xNAN;**`CUSTOM_QUOTE_TITLE`**: (String) title of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_CONTENT`**: (String) content / subtitle of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_IMAGE_URL_STRING`**: (String) image url string of custom quote image\
\&#xNAN;**`USER_INFO`**: (String) client-specified data or details of the custom quote
{% endhint %}

### Create Room with Room Model

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

```csharp
#import <TapTalk/TapUI.h>

[[TapUI sharedInstance] createRoomWithRoom:ROOM success:^(TapUIChatViewController * _Nonnull chatViewController) {
   // You can choose to present or push view controller
   
   // Present room list view
   [self presentViewController:chatViewController animated:YES completion:^{
        // Completion
   }];

   // Push room list view
   [self.navigationController pushViewController:chatViewController animated:YES];
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`ROOM`**: (TAPRoomModel) recipient room data model
{% endhint %}

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

```csharp
#import <TapTalk/TapUI.h>

[[TapUI sharedInstance] createRoomWithRoom:ROOM customQuoteTitle:CUSTOM_QUOTE_TITLE customQuoteContent:CUSTOM_QUOTE_CONTENT customQuoteImageURLString:CUSTOM_QUOTE_IMAGE_URL_STRING userInfo:USER_INFO success:^(TapUIChatViewController * _Nonnull chatViewController) {
   // You can choose to present or push view controller
   
   // Present room list view
   [self presentViewController:chatViewController animated:YES completion:^{
      // Completion
   }];

   // Push room list view
   [self.navigationController pushViewController:chatViewController animated:YES];
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`ROOM`**: (TAPRoomModel) recipient room data model\
\&#xNAN;**`CUSTOM_QUOTE_TITLE`**: (String) title of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_CONTENT`**: (String) content / subtitle of custom quote data\
\&#xNAN;**`CUSTOM_QUOTE_IMAGE_URL_STRING`**: (String) image url string of custom quote image\
\&#xNAN;**`USER_INFO`**: (String) client-specified data or details of the custom quote
{% endhint %}

### Create Room with Room Model & Scroll to Selected Message

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

```csharp
#import <TapTalk/TapUI.h>

[[TapUI sharedInstance] createRoomWithRoom:ROOM scrollToMessageWithLocalID:MESSAGE_LOCAL_ID] success:^(TapUIChatViewController * _Nonnull chatViewController) {
   // You can choose to present or push view controller
   // Present room list view
   [self presentViewController:chatViewController animated:YES completion:^{
       // Completion
   }];

   // Push room list view
   [self.navigationController pushViewController:chatViewController animated:YES];
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`ROOM`**: (TAPRoomModel) recipient room data model\
\&#xNAN;**`MESSAGE_LOCAL_ID`**: (String) scrolls the view to the message with the specified local ID when the chat room is opened
{% endhint %}

### Create Saved Messages Chat Room

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

```csharp
#import <TapTalk/TapUI.h>

[[TapUI sharedInstance] createSavedMessagesChatRoom:^(TapUIChatViewController * _Nonnull chatViewController) {
    // Successfully created Saved Messages chat room
  
    // You can choose to present or push view controller
    // Present room list view
    [self presentViewController:chatViewController animated:YES completion:^{
        // Completion    
    }];

    // Push room list view
    [self.navigationController pushViewController:chatViewController animated:YES];
}
failure:^(NSError * _Nonnull error) {
    // Failed to create room
}];
```

{% endtab %}
{% endtabs %}


---

# 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://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/group-chat/group-chat-tapui.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.
