> 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/event-delegate.md).

# Event Delegate

The iOS SDK provides event delegates to listen to various events on the client app. Through these event delegates, TapTalk.io notifies the client app of events that happen on your app. You will need to register the delegate objects to receive event callbacks from TapTalk.io.

| **Event Delegate Name**                                                                                                                                                               | **Description**                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [TapTalkDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#taptalkdelegate)                                                           | Listens to general event changes in the application                                                            |
| [TapUIRoomListDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#tapuiroomlistdelegate)                                               | Listens to UI-related events in **Room List View** when UI implementation type is used                         |
| [TapUIChatRoomDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#tapuichatroomdelegate)                                               | Listens to UI-related events in **Chat Room View** when UI implementation type is used                         |
| [TapUIChatProfileDelegate](#tapuichatprofiledelegate)                                                                                                                                 | Listens to UI-related events in **Chat Profile View** when UI implementation type is used                      |
| [TapUIMyAccountDelegate](#tapuimyaccountdelegate)                                                                                                                                     | Listens to UI-related events in **My Account View** when UI implementation type is used                        |
| [TapUICustomKeyboardDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#tapuicustomkeyboarddelegate)                                   | Listens to custom keyboard-related events when UI implementation type is used                                  |
| [TAPCoreMessageManagerDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#tapcoremessagemanagerdelegate)                               | Listens to events when a new/updated message is received by the application                                    |
| [TAPCoreRoomListManagerDelegate](#tapcoreroomlistmanagerdelegate)                                                                                                                     | Listens to changes to chat room's state in the room list                                                       |
| [TAPCoreChatRoomManagerDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#tapcorechatroommanagerdelegate)                             | Listens to chat room status events such as typing events and online status                                     |
| [TAPCoreContactManagerDelegate](#tapcorecontactmanagerdelegate)                                                                                                                       | Listens to contact related events such as block or unblock contact                                             |
| [TapUIRoomListViewControllerLifecycleDelegate](https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/event-delegate.md#tapuiroomlistviewcontrollerlifecycledelegate) | Listens to room list view controller lifecycle methods such as `viewDidLoad`, `viewWillAppear`, and many more. |

### TapTalkDelegate

General events such as notifications will be notified through `TapTalkDelegate`. A `TapTalkDelegate` instance is required when initializing TapTalk.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

//Add TapTalkDelegate declaration
@interface ViewController () <TapTalkDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapTalk delegate to current view controller
    [[TapTalk sharedInstance] setDelegate:self];
}

#pragma mark - TapTalkDelegate

- (void)tapTalkRefreshTokenExpired {
    // Authentication is needed
}

- (void)tapTalkDidTappedNotificationWithMessage:(TAPMessageModel *_Nonnull)message fromActiveController:(nullable UIViewController *)currentActiveController {
    // Handle tapped notification message
}

- (void)tapTalkUnreadChatRoomBadgeCountUpdated:(NSInteger)numberOfUnreadRooms {
    // Returns number of unread messages from the application
}

- (void)tapTalkDidRequestRemoteNotification {
    // Register for remote notification
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}

- (void)userLogout {
    // User has logged out
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapTalkDelegate {
    
    override func viewDidLoad() {
        // Set TapTalk delegate to current view controller
        TapTalk.sharedInstance().delegate = self
    }
    
    // MARK: TapTalkDelegate
    
    func tapTalkRefreshTokenExpired() {
        // Authentication is needed
    }
    
    func tapTalkDidTappedNotification(withMessage message: TAPMessageModel, fromActiveController currentActiveController: UIViewController?) {
        // Handle tapped notification message
    }
    
    func tapTalkUnreadChatRoomBadgeCountUpdated(_ numberOfUnreadRooms: Int) {
        // Returns number of unread messages from the application
    }
    
    func tapTalkDidRequestRemoteNotification() {
        // Register for remote notification
        UIApplication.shared.registerForRemoteNotifications()
    }
    
    func userLogout() {
        // User has logged out
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                                                                                                                         | **Invoked When**                                                                                                                                                                                                                                                                                                                                                                                           |
| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`tapTalkRefreshTokenExpired`**                                                                                                        | User's refresh token has expired. Authentication with a new auth ticket is required.                                                                                                                                                                                                                                                                                                                       |
| **`tapTalkUnreadChatRoomBadgeCountUpdated:`**                                                                                           | <p>The number of unread messages in the application is updated. Returns the <strong>number</strong> of unread messages from the application.<br><br>Call method <code>updateApplicationBadgeCount</code> to update unread badge counter. You can see the function explanation in <a href="https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/general.md">General section page</a>.</p> |
| <p><strong><code>tapTalkDidTappedNotificationWithMessage:</code></strong></p><p><strong><code>fromActiveController:</code></strong></p> | User tapped the notification.                                                                                                                                                                                                                                                                                                                                                                              |
| **`tapTalkDidRequestRemoteNotification`**                                                                                               | TapTalk.io needs to request for push notification, usually client needs to add`[UIApplication sharedApplication] registerForRemoteNotifications]`inside the method.                                                                                                                                                                                                                                        |
| **`userLogout`**                                                                                                                        | User has logged out and all user data has been cleared from local storage                                                                                                                                                                                                                                                                                                                                  |

### TapUIRoomListDelegate

TapUIRoomListDelegate listens to UI-related events in **Room List View** when UI implementation type is used. You can register a TapUIRoomListDelegate instance in your application through the TapUI class as follows:

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TapUIDelegate declaration
@interface ViewController () <TapUIRoomListDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapUI delegate to current view controller
    [[TapUI sharedInstance] setRoomListDelegate:self];
}

#pragma mark - TapUIRoomListDelegate
  
// Called when user taps the profile button on the top left side of room list view
- (void)tapTalkAccountButtonTapped:(UIViewController *)currentViewController
  currentShownNavigationController:(UINavigationController *)currentNavigationController {
                                   
}

// Called when user taps the new chat button on the top right side of room list view
- (void)tapTalkNewChatButtonTapped:(UIViewController *)currentViewController
  currentShownNavigationController:(UINavigationController *)currentNavigationController {
  
}

// Called when user taps the close button on the top left side of room list view
- (void)tapTalkCloseRoomListButtonTapped:(UIViewController *)currentViewController
        currentShownNavigationController:(UINavigationController *)currentNavigationController {
  
}

@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapUIRoomListDelegate {
    
    override func viewDidLoad() {
        // Set TapUI delegate to current view controller
        TapUI.sharedInstance().roomListDelegate = self
    }
    
    // MARK: TapUIRoomListDelegate
    
    // Called when user clicks the profile button on the top right side of group chat room page.
    func tapTalkAccountButtonTapped(_ currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps the new chat button on the top right side of room list view
    func tapTalkNewChatButtonTapped(_ currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps the close button on the top left side of room list view
    func tapTalkCloseRoomListButtonTapped(_ currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                                                                                                                              | **Invoked When**                                                                   |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong><code>tapTalkAccountButtonTapped:</code></strong></p><p><strong><code>currentShownNavigationController:</code></strong></p>       | My account button in the top left side of room list view is tapped by active user. |
| <p><strong><code>tapTalkNewChatButtonTapped:</code></strong></p><p><strong><code>currentShownNavigationController:</code></strong></p>       | New Chat button in the top right side of room list view is tapped by active user.  |
| <p><strong><code>tapTalkCloseRoomListButtonTapped:</code></strong></p><p><strong><code>currentShownNavigationController:</code></strong></p> | Close room list button is tapped by active user.                                   |

### TapUIChatRoomDelegate

TapUIChatRoomDelegate listens to UI-related events in **Chat Room View** when UI implementation type is used. You can register a TapUIChatRoomDelegate instance in your application through the TapUI class as follows:

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TapUIDelegate declaration
@interface ViewController () <TapUIChatRoomDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapUI delegate to current view controller
    [[TapUI sharedInstance] setChatRoomDelegate:self];
}

#pragma mark - TapUIChatRoomDelegate

// Called when a chat room is opened
- (void)tapTalkChatRoomDidOpen:(TAPRoomModel *)room
         currentViewController:(UIViewController *)currentViewController
currentShownNavigationController:(UINavigationController *)currentNavigationController {

}

// Called when a chat room is closed
- (void)tapTalkChatRoomDidClose:(TAPRoomModel *)room
          currentViewController:(UIViewController *)currentViewController
currentShownNavigationController:(UINavigationController *)currentNavigationController {

}

// Called when active user sends any message to a chat room
- (void)tapTalkActiveUserDidSendMessage:(TAPMessageModel *)message
                                   room:(TAPRoomModel *)room
                  currentViewController:(UIViewController *)currentViewController
       currentShownNavigationController:(UINavigationController *)currentNavigationController {
       
 }
  
// Called when user taps the profile button on the top right side of the personal chat room view
- (void)tapTalkChatRoomProfileButtonTapped:(UIViewController *)currentViewController
                                 otherUser:(TAPUserModel *)otherUser
                                      room:(TAPRoomModel *)room
          currentShownNavigationController:(UINavigationController *)currentNavigationController {
                                   
}

// Called when user taps the profile button on the top right side of the group chat room view
- (void)tapTalkGroupChatRoomProfileButtonTapped:(UIViewController *)currentViewController
                                           room:(TAPRoomModel *)room
               currentShownNavigationController:(UINavigationController *)currentNavigationController {

}

// Called when user taps the profile button on user in group
- (void)tapTalkGroupMemberAvatarTappedWithRoom:(TAPRoomModel *)room
                                          user:(TAPUserModel *)user
              currentShownNavigationController:(UINavigationController *)currentNavigationController {
}

// Called when user taps mention in the bubble chat
- (void)tapTalkUserMentionTappedWithRoom:(TAPRoomModel *)room
                           mentionedUser:(TAPUserModel *)mentionedUser
                       isRoomParticipant:(BOOL)isRoomParticipant
                                 message:(TAPMessageModel *)message
                   currentViewController:(UIViewController *)currentViewController
        currentShownNavigationController:(UINavigationController *)currentNavigationController {
 
 }

// Called when user taps the quote view that appears in the chat bubble
- (void)tapTalkMessageQuoteTappedWithUserInfo:(NSDictionary *)userInfo {
  
}

// Called when multiple message selection (e.g. forward) is shown in active chat room
- (void)tapTalkChatRoomDidShowMessageSelection:(NSArray<TAPMessageModel *> *)selectedMessages {

}

// Called when multiple message selection is hidden or cancelled in active chat room
- (void)tapTalkChatRoomDidHideMessageSelection {

}

// Called when user selects report message menu in chat room
- (void)tapTalkReportMessageButtonDidTapped:(UIViewController *)currentViewController
                                    message:(TAPMessageModel *)message
           currentShownNavigationController:(UINavigationController *)currentNavigationController {
           
}

@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapUIChatRoomDelegate {
    
    override func viewDidLoad() {
        // Set TapUI delegate to current view controller
        TapUI.sharedInstance().chatRoomDelegate = self
    }
    
    // MARK: TapUIChatRoomDelegate
    
    // Called when a chat room is opened
    func tapTalkChatRoomDidOpen(_ room: TAPRoomModel, otherUser: TAPUserModel?, currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when a chat room is closed
    func tapTalkChatRoomDidClose(_ room: TAPRoomModel, otherUser: TAPUserModel?, currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when active user sends any message to a chat room
    func tapTalkActiveUserDidSendMessage(_ message: TAPMessageModel, room: TAPRoomModel, currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps the profile button on the top right side of the personal chat room view
    func tapTalkChatRoomProfileButtonTapped(_ currentViewController: UIViewController, otherUser: TAPUserModel, room: TAPRoomModel, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps the profile button on the top right side of the group chat room view
    func tapTalkGroupChatRoomProfileButtonTapped(_ currentViewController: UIViewController, room: TAPRoomModel, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps the profile button on user in group
    func tapTalkGroupMemberAvatarTapped(withRoom room: TAPRoomModel, user: TAPUserModel, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps mention in the bubble chat
    func tapTalkUserMentionTapped(withRoom room: TAPRoomModel, mentionedUser: TAPUserModel, isRoomParticipant: Bool, message: TAPMessageModel, currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
    
    // Called when user taps the quote view that appears in the chat bubble
    func tapTalkMessageQuoteTapped(userInfo: [AnyHashable : Any] = [:]) {
        
    }
    
    // Called when multiple message selection (e.g. forward) is shown in active chat room
    func tapTalkChatRoomDidShowMessageSelection(_ selectedMessages: [TAPMessageModel]) {
        
    }
    
    // Called when multiple message selection is hidden or cancelled in active chat room
    func tapTalkChatRoomDidHideMessageSelection() {
        
    }
    
    // Called when user selects report message menu in chat room
    func tapTalkReportMessageButtonDidTapped(_ currentViewController: UIViewController, message: TAPMessageModel, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                                                                                                                                                                                                                                                                                                                                                | **Invoked When**                                                                                                                                                                                                                                                     |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`tapTalkChatRoomDidOpen:`**                                                                                                                                                                                                                                                                                                                                  | A chat room is opened. Returns the opened room, current shown view controller, and current shown navigation controller.                                                                                                                                              |
| **`tapTalkChatRoomDidClose:`**                                                                                                                                                                                                                                                                                                                                 | A chat room is closed. Returns the closed room, current shown view controller, and current shown navigation controller.                                                                                                                                              |
| **`tapTalkActiveUserDidSendMessage:`**                                                                                                                                                                                                                                                                                                                         | Active user sends any message to a chat room. Message may not yet be delivered to the room when this happens. Returned message is temporary and the values will be updated through socket once the message is delivered.                                             |
| **`tapTalkChatRoomProfileButtonTapped:`**                                                                                                                                                                                                                                                                                                                      | <p>My account button in top left room list view is tapped by active user.</p><p><strong><code>tapTalkUnreadChatRoomBadgeCountUpdated:</code></strong></p>                                                                                                            |
| **`tapTalkGroupChatRoomProfileButtonTapped:`**                                                                                                                                                                                                                                                                                                                 | Profile button in a group chat room is tapped by active user. Returns the current shown navigation controller.                                                                                                                                                       |
| **`tapTalkGroupMemberAvatarTappedWithRoom:`**                                                                                                                                                                                                                                                                                                                  | A group member's profile picture on a message bubble in group chat room is tapped by active user. Returns the current shown navigation controller.                                                                                                                   |
| <p><strong><code>tapTalkUserMentionTappedWithRoom:</code></strong></p><p><strong><code>mentionedUser:</code></strong></p><p><strong><code>isRoomParticipant:</code></strong></p><p><strong><code>message:</code></strong></p><p><strong><code>currentViewController:</code></strong></p><p><strong><code>currentShownNavigationController:</code></strong></p> | Mention in bubble chat is tapped by active user. Returns current room, mentioned user data, boolean indicating the user is in group participant or not, message data, current shown view controller, and current shown navigation controller.                        |
| **`tapTalkMessageQuoteTappedWithUserInfo:`**                                                                                                                                                                                                                                                                                                                   | <p>A quote inside a message bubble in a chat room is tapped by active user. Returns tapped message, and userInfo.</p><p>UserInfo is a dictionary object embedded inside a message containing data specified by client, and is generally null when not specified.</p> |
| **`tapTalkChatRoomDidShowMessageSelection:selectedMessages:`**                                                                                                                                                                                                                                                                                                 | Active user starts selecting messages and multiple message selection (e.g. forward) is shown in active chat room.                                                                                                                                                    |
| **`tapTalkChatRoomDidHideMessageSelection`**                                                                                                                                                                                                                                                                                                                   | Multiple message selection is hidden or cancelled by active user.                                                                                                                                                                                                    |
| **`tapTalkReportMessageButtonDidTapped:message:currentShownNavigationController:`**                                                                                                                                                                                                                                                                            | Active user selects Report Message from a message bubble's long press menu.                                                                                                                                                                                          |

### TapUIChatProfileDelegate

TapUIChatProfileDelegate listens to UI-related events in **Chat Profile View** when UI implementation type is used. You can register a TapUIChatProfileDelegate instance in your application through the TapUI class as follows:

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TapUIDelegate declaration
@interface ViewController () <TapUIChatProfileDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapUI delegate to current view controller
    [[TapUI sharedInstance] setChatProfileDelegate:self];
}

#pragma mark - TapUIChatProfileDelegate
  
// Called when user taps Report User button in user profile
- (void)reportUserButtonDidTapped:(UIViewController *)currentViewController
                             room:(TAPRoomModel *)room
                             user:(TAPUserModel *)reportedUser {
                                   
}

// Called when user taps Report Group button in group profile
- (void)reportGroupButtonDidTapped:(UIViewController *)currentViewController
                              room:(TAPRoomModel *)room {
                                   
}
                          
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapUIChatProfileDelegate {
    
    override func viewDidLoad() {
        // Set TapUI delegate to current view controller
        TapUI.sharedInstance().chatProfileDelegate = self
    }
    
    // MARK: TapUIChatProfileDelegate
    
    // Called when user taps Report User button in user profile
    func reportUserButtonDidTapped(_ currentViewController: UIViewController, room: TAPRoomModel, user reportedUser: TAPUserModel) {
        
    }
    
    // Called when user taps Report Group button in group profile
    func reportGroupButtonDidTapped(_ currentViewController: UIViewController, room: TAPRoomModel) {
        
    }    
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                            | **Invoked When**                                                     |
| ------------------------------------------ | -------------------------------------------------------------------- |
| **`reportUserButtonDidTapped:room:user:`** | Active user taps Report User button in another user's profile page.  |
| **`reportGroupButtonDidTapped:room:`**     | Active user taps Report Group button in a chat group's profile page. |

### TapUIMyAccountDelegate

TapUIMyAccountDelegate listens to UI-related events in **My Account View** when UI implementation type is used. You can register a TapUIMyAccountDelegate instance in your application through the TapUI class as follows:

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TapUIDelegate declaration
@interface ViewController () <TapUIMyAccountDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapUI delegate to current view controller
    [[TapUI sharedInstance] setMyAccountDelegate:self];
}

#pragma mark - TapUIMyAccountDelegate
  
// Called when user tapped Delete Account button in my account page
- (void)tapTalkDeleteAccountButtonTapped:(UIViewController *)currentViewController
        currentShownNavigationController:(UINavigationController *)currentNavigationController {
                                   
}

@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapUIMyAccountDelegate {
    
    override func viewDidLoad() {
        // Set TapUI delegate to current view controller
        TapUI.sharedInstance().myAccountDelegate = self
    }
    
    // MARK: TapUIMyAccountDelegate
    
    // Called when user tapped Delete Account button in my account page
    func tapTalkDeleteAccountButtonTapped(_ currentViewController: UIViewController, currentShownNavigationController currentNavigationController: UINavigationController) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                                                          | **Invoked When**                                                            |
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| **`tapTalkDeleteAccountButtonTapped:currentShownNavigationController:`** | Active user taps Delete Account button in their own account's profile page. |

### TapUICustomKeyboardDelegate

TapUICustomKeyboardDelegate bridges the custom keyboard-related events between TapTalk.io and the client app when UI implementation type is used. TapTalk.io will request custom keyboard items from the client app through this listener when a chat room is opened by the user. TapUICustomKeyboardDelegate can be implemented using the TapUI class.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TapUIChatProfileDelegate declaration
@interface ViewController () <TapUICustomKeyboardDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
  // Set TapUI delegate to current view controller
  [[TapUI sharedInstance] setCustomKeyboardDelegate:self];
}

#pragma mark - TapUICustomKeyboardDelegate

- (void)customKeyboardItemTappedWithRoom:(TAPRoomModel * _Nonnull)room
                                  sender:(TAPUserModel * _Nonnull)sender
                               recipient:(TAPUserModel * _Nullable)recipient
                            keyboardItem:(TAPCustomKeyboardItemModel * _Nonnull)keyboardItem {
    // Do an action when user taps a custom keyboard item
}


- (NSArray<TAPCustomKeyboardItemModel *> *)setCustomKeyboardItemsForRoom:(TAPRoomModel * _Nonnull)room sender:(TAPUserModel * _Nonnull)sender recipient:(TAPUserModel * _Nullable)recipient {
    // Set custom keyboard option items
    // Return items here if you wish to use custom keyboard in chat room
    return [NSArray array];
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapUICustomKeyboardDelegate {
    
    override func viewDidLoad() {
        // Set TapUI delegate to current view controller
        TapUI.sharedInstance().customKeyboardDelegate = self
    }
    
    // MARK: TapUICustomKeyboardDelegate
    
    func customKeyboardItemTapped(withRoom room: TAPRoomModel, sender: TAPUserModel, recipient: TAPUserModel?, keyboardItem: TAPCustomKeyboardItemModel) {
        // Do an action when user taps a custom keyboard item
    }
    
    func setCustomKeyboardItemsForRoom(_ room: TAPRoomModel, sender: TAPUserModel, recipient: TAPUserModel?) -> [TAPCustomKeyboardItemModel] {
        // Set custom keyboard option items
        // Return items here if you wish to use custom keyboard in chat room
        return Array()
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

To use custom keyboard in the chat room, return a list of **`TapCustomKeyboardItemModel`** on the **`setCustomKeyboardItemsForRoom:`** method in this delegate. See the example below:

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

```objective-c
- (NSArray<TAPCustomKeyboardItemModel *> *)setCustomKeyboardItemsForRoom:(TAPRoomModel * _Nonnull)room
                                                                  sender:(TAPUserModel * _Nonnull)sender
                                                               recipient:(TAPUserModel * _Nullable)recipient {
  
    NSMutableArray *customKeyboardItemArray = [NSMutableArray array];
    
    TAPCustomKeyboardItemModel *customKeyboardItem1 = [TAPCustomKeyboardItemModel new];
    customKeyboardItem1.itemName = @"Item 1";
    customKeyboardItem1.iconURL = @"Item Icon URL 1";
    [customKeyboardItemArray addObject:customKeyboardItem1];
    
    TAPCustomKeyboardItemModel *customKeyboardItem2 = [TAPCustomKeyboardItemModel new];
    customKeyboardItem2.itemName = @"Item 2";
    customKeyboardItem2.iconURL = @"Item Icon URL 2";
    [customKeyboardItemArray addObject:customKeyboardItem2];
    
    return customKeyboardItemArray;
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
func setCustomKeyboardItemsForRoom(_ room: TAPRoomModel, sender: TAPUserModel, recipient: TAPUserModel?) -> [TAPCustomKeyboardItemModel] {
    var customKeyboardItemArray: [TAPCustomKeyboardItemModel] = []
    
    var customKeyboardItem1 = TAPCustomKeyboardItemModel()
    customKeyboardItem1.itemName = "Item 1"
    customKeyboardItem1.iconURL = "Item Icon URL 1"
    customKeyboardItemArray.append(customKeyboardItem1)
    
    var customKeyboardItem2 = TAPCustomKeyboardItemModel()
    customKeyboardItem2.itemName = "Item 2"
    customKeyboardItem2.iconURL = "Item Icon URL 2"
    customKeyboardItemArray.append(customKeyboardItem2)
    
    return customKeyboardItemArray
}
```

{% endtab %}
{% endtabs %}

| **Method Name**                                                                                                                                                                                                     | **Invoked When**                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>customKeyboardItemTappedWithRoom:</code></strong></p><p><strong><code>sender:</code></strong></p><p><strong><code>recipient:</code></strong></p><p><strong><code>keyboardItem:</code></strong></p> | A custom keyboard item in a chat room is tapped by the user. Returns **custom keyboard item**, **room**, **sender user**, and **recipient user** (only for personal chat room)                                       |
| **`setCustomKeyboardItemsForRoom:sender:recipient:`**                                                                                                                                                               | Chat room is opened. TapTalk.io will request custom keyboard items from the client app to be displayed in the chat room. Returns **room**, **sender user**, and the **recipient user** (only for personal chat room) |

### TAPCoreMessageManagerDelegate

TAPCoreMessageManagerDelegate listens to events when a new/updated message is received by the application. TAPCoreMessageManagerDelegate can be registered through the TapCoreMessageManager class.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TAPCoreMessageManagerDelegate declaration
@interface ViewController () <TAPCoreMessageManagerDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TAPCoreMessageManager delegate to current view controller
    [[TAPCoreMessageManager sharedManager] setDelegate:self];
}

#pragma mark - TAPCoreMessageManagerDelegate

- (void)tapTalkDidReceiveNewMessage:(TAPMessageModel *)message {

}

- (void)tapTalkDidReceiveUpdatedMessage:(TAPMessageModel *)message {
  
}

- (void)tapTalkDidDeleteMessage:(TAPMessageModel *)message {
  
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TAPCoreMessageManagerDelegate {
    
    override func viewDidLoad() {
        // Set TAPCoreMessageManager delegate to current view controller
        TAPCoreMessageManager.shared().delegate = self
    }
    
    // MARK: TAPCoreMessageManagerDelegate
    
    func tapTalkDidReceiveNewMessage(_ message: TAPMessageModel) {
        
    }
    
    func tapTalkDidReceiveUpdatedMessage(_ message: TAPMessageModel) {
        
    }
    
    func tapTalkDidDeleteMessage(_ message: TAPMessageModel) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                        | **Invoked When**                                                        |
| -------------------------------------- | ----------------------------------------------------------------------- |
| **`tapTalkDidReceiveNewMessage:`**     | A new message is received. Returns the newly received **message**.      |
| **`tapTalkDidReceiveUpdatedMessage:`** | An updated message is received. Returns the newly received **message**. |
| **`tapTalkDidDeleteMessage:`**         | A message is deleted. Returns the deleted **message**.                  |

### TAPCoreRoomListManagerDelegate

Changes to a chat room's state, such as pin and mute events are notified through TapCoreRoomListListener. An instance of TapCoreRoomListListener can be registered from the **TapCoreRoomListManager** class.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TAPCoreRoomListManagerDelegate declaration
@interface ViewController () <TAPCoreRoomListManagerDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TAPCoreRoomListManager delegate to current view controller
    [[TAPCoreRoomListManager sharedManager] setDelegate:self];
}

#pragma mark - TAPCoreRoomListManagerDelegate

- (void)tapTalkDidMuteChatRoom:(NSString *)roomID expiredAt:(NSNumber *)expiredAt {

}

- (void)tapTalkDidUnmuteChatRoom:(NSString *)roomID {

}

- (void)tapTalkDidPinChatRoom:(NSString *)roomID {

}

- (void)tapTalkDidUnpinChatRoom:(NSString *)roomID {

}

- (void)tapTalkDidDeleteChatRoom:(NSString *)roomID {

}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewContoller.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TAPCoreRoomListManagerDelegate {
    
    override func viewDidLoad() {
        // Set TAPCoreMessageManager delegate to current view controller
        TAPCoreRoomListManager.shared().delegate = self
    }
    
    // MARK: TAPCoreRoomListManagerDelegate
    
    func tapTalkDidMuteChatRoom(_ roomID: String, expiredAt: NSNumber) {
        
    }
    
    func tapTalkDidUnmuteChatRoom(_ roomID: String) {
        
    }
    
    func tapTalkDidPinChatRoom(_ roomID: String) {
        
    }
    
    func tapTalkDidUnpinChatRoom(_ roomID: String) {
        
    }
    
    func tapTalkDidDeleteChatRoom(_ roomID: String) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| Method Name                     | Invoked When                                                                                           |
| ------------------------------- | ------------------------------------------------------------------------------------------------------ |
| **`tapTalkDidMuteChatRoom:`**   | The active user muted a chat room. Returns the **room ID** and **mute expiry time** of the muted room. |
| **`tapTalkDidUnmuteChatRoom:`** | The active user unmuted a chat room. Returns the **room ID** of the unmuted room.                      |
| **`tapTalkDidPinChatRoom:`**    | The active user pinned a chat room. Returns the **room ID** of the pinned room.                        |
| **`tapTalkDidUnpinChatRoom:`**  | The active user unpinned a chat room. Returns the **room ID** of the unpinned room.                    |
| **`tapTalkDidDeleteChatRoom:`** | The active user deleted a chat room. Returns the **room ID** of the deleted room.                      |

### TAPCoreChatRoomManagerDelegate

Room status events such as typing events and online status are notified through TAPCoreChatRoomManagerDelegate. An instance of TAPCoreChatRoomManagerDelegate can be registered from the **TapCoreChatRoomManager** class.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TAPCoreChatRoomManagerDelegate declaration
@interface ViewController () <TAPCoreChatRoomManagerDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TAPCoreChatRoomManager delegate to current view controller
    [[TAPCoreChatRoomManager sharedManager] setDelegate:self];
}

#pragma mark - TAPCoreChatRoomManagerDelegate

- (void)tapTalkDidReceiveUpdatedChatRoomData:(TAPRoomModel *)room recipientUser:(TAPUserModel *_Nullable)recipientUser {

}

- (void)tapTalkDidStartTypingWithUser:(TAPUserModel *)user roomID:(NSString *)roomID {
  
}

- (void)tapTalkDidStopTypingWithUser:(TAPUserModel *)user roomID:(NSString *)roomID {

}

- (void)tapTalkDidReceiveOnlineStatusWithUser:(TAPUserModel *)user onlineStatus:(BOOL)isOnline lastActive:(NSNumber *)lastActive {
  
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TAPCoreChatRoomManagerDelegate {
    
    override func viewDidLoad() {
        // Set TAPCoreChatRoomManager delegate to current view controller
        TAPCoreChatRoomManager.shared().delegate = self
    }
    
    // MARK: TAPCoreChatRoomManagerDelegate
    
    func tapTalkDidReceiveUpdatedChatRoomData(_ room: TAPRoomModel, recipientUser: TAPUserModel?) {
        
    }
    
    func tapTalkDidStartTyping(withUser user: TAPUserModel, roomID: String) {
        
    }
    
    func tapTalkDidStopTyping(withUser user: TAPUserModel, roomID: String) {
        
    }
    
    func tapTalkDidReceiveOnlineStatus(withUser user: TAPUserModel, onlineStatus isOnline: Bool, lastActive: NSNumber) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                                           | **Invoked When**                                                                                                                          |
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **`tapTalkDidReceiveUpdatedChatRoomData:recipientUser:`** | An updated chat room data was received through socket message. Returns the **room** data and **user** data for personal room.             |
| **`tapTalkDidStartTypingWithUser:roomID:`**               | Another user starts typing a message in a chat room. Returns the **room ID** and **typing user**.                                         |
| **`tapTalkDidStopTypingWithUser:roomID:`**                | Another user stops typing a message in a chat room. Returns the **room ID** and **typing user**.                                          |
| **`tapTalkDidReceiveOnlineStatus:`**                      | Another user comes online or offline. Returns the **updated user**, **online status**, and the updated user's last active **time stamp**. |

### TAPCoreContactManagerDelegate

Contact related events such as block/unblock are notified through TAPCoreContactManagerDelegate. An instance of TAPCoreContactManagerDelegate can be registered from the **TapCoreContactManager** class.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TAPCoreContactManagerDelegate declaration
@interface ViewController () <TAPCoreContactManagerDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapCoreContactManager delegate to current view controller
    [[TapCoreContactManager sharedManager] setDelegate:self];
}

#pragma mark - TapCoreContactManagerDelegate

- (void)tapTalkDidBlockContact:(TAPUserModel *)user {
  
}

- (void)tapTalkDidUnblockContact:(TAPUserModel *)user {
  
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TAPCoreContactManagerDelegate {
    
    override func viewDidLoad() {
        // Set TAPCoreContactManagerDelegate delegate to current view controller
        TAPCoreContactManager.shared().delegate = self
    }
    
    // MARK: TAPCoreContactManagerDelegate
    
    func tapTalkDidBlockContact(_ user: TAPUserModel) {
        
    }
    
    func tapTalkDidUnblockContact(_ user: TAPUserModel) {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

| **Method Name**                 | **Invoked When**                                                   |
| ------------------------------- | ------------------------------------------------------------------ |
| **`tapTalkDidBlockContact:`**   | Active user blocks another user. Returns the blocked **user**.     |
| **`tapTalkDidUnblockContact:`** | Active user unblocks another user. Returns the unblocked **user**. |

### TapUIRoomListViewControllerLifecycleDelegate

Room list view controller lifecycle events such as `loadView`, `viewDidLoad`, `viewWillAppear` and others are notified through TAPRoomListViewControllerLifecycleDelegate.

{% tabs %}
{% tab title="Objective-C" %}
{% code title="ViewController.m" %}

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

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

// Add TapUIDelegate declaration
@interface ViewController () <TapUIRoomListViewControllerLifecycleDelegate>

@end
  
@implementation ViewController
  
- (void)viewDidLoad {
    // Set TapUI delegate to current view controller
    [[[TapUI sharedInstance] roomListViewController] setLifecycleDelegate:self];
}

#pragma mark - TapUIRoomListViewControllerLifecycleDelegate
  
- (void)TapUIRoomListViewControllerLoadView {
  
}

- (void)TapUIRoomListViewControllerViewDidLoad {
  
}

- (void)TapUIRoomListViewControllerViewWillAppear {
  
}

- (void)TapUIRoomListViewControllerViewWillDisappear {
  
}

- (void)TapUIRoomListViewControllerViewDidAppear {
  
}

- (void)TapUIRoomListViewControllerViewDidDisappear {
  
}

- (void)TapUIRoomListViewControllerDealloc {
  
}

- (void)TapUIRoomListViewControllerDidReceiveMemoryWarning {
  
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code title="ViewController.swift" %}

```swift
import PowerTalk

class ViewController: UIViewController, TapUIRoomListViewControllerLifecycleDelegate {
    
    override func viewDidLoad() {
        // Set TapUI delegate to current view controller
        TapUI.sharedInstance().roomListViewController().lifecycleDelegate = self
    }
    
    // MARK: TapUIRoomListViewControllerLifecycleDelegate
    
    func tapUIRoomListViewControllerLoadView() {
        
    }
    
    func tapUIRoomListViewControllerViewDidLoad() {
        
    }
    
    func tapUIRoomListViewControllerViewWillAppear() {
        
    }
    
    func tapUIRoomListViewControllerViewWillDisappear() {
        
    }
    
    func tapUIRoomListViewControllerViewDidAppear() {
        
    }
    
    func tapUIRoomListViewControllerViewDidDisappear() {
        
    }
    
    func tapUIRoomListViewControllerDealloc() {
        
    }
    
    func tapUIRoomListViewControllerDidReceiveMemoryWarning() {
        
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
