> 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/onetalk-omnichannel-documentation/onetalk-channel-integration/live-chat/onetalk-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**                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- |
| [TapTalkLiveDelegate](https://docs.taptalk.io/onetalk-omnichannel-documentation/onetalk-channel-integration/live-chat/onetalk-ios/event-delegate.md#taptalklivedelegate) | Listens to general event changes in the application |

### TapTalkLiveDelegate

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

{% hint style="info" %}
**Note:** Make sure to add **`#import <TapTalkLive/TapTalkLive.h>`** before registering the delegate
{% endhint %}

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

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

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

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

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

#pragma mark - TapTalkLiveDelegate

- (void)didTappedCloseButtonInHomePageViewWithCurrentShownNavigationController:(UINavigationController *)navigationController {
    // User taps close button in home page
}

- (void)didTappedCloseButtonInCreateCaseViewWithCurrentShownNavigationController:(UINavigationController *)navigationController {
    // User taps close button in create case form
}

- (void)didTappedCloseButtonInCaseListViewWithCurrentShownNavigationController:(UINavigationController *)navigationController {
    // User taps close button in case list page
}

- (void)seeAllMessagesButtonDidTappedWithCurrentShownNavigationController:(UINavigationController *)navigationController {
    // User taps the See All Messages button in home page
    // Implementing this will prevent opening the case list page by default
}

- (void)createNewMessageButtonDidTappedWithCurrentShownNavigationController:(UINavigationController *)navigationController {
    // User taps the New Messages button in home or case list page
    // Implementing this will prevent opening the create new case form by default
}

- (void)caseListItemDidTappedWithCurrentShownNavigationController:(UINavigationController *)navigationController lastMessage:(TAPMessageModel *)lastMessage {
    // User taps a case from a list in home or case list page
    // Implementing this will prevent opening the selected chat room by default
}

- (void)faqChildDidTapped:(TTLFaqModel *)faqModel currentShownNavigationController:(UINavigationController *)navigationController {
    // User taps a FAQ from a list in home or FAQ details page
    // Implementing this will prevent opening the selected FAQ details page by default
}

- (void)closeButtonInFaqDetailsViewDidTapped:(TTLFaqModel *)faqModel currentShownNavigationController:(UINavigationController *)navigationController {
    // User closes the FAQ details page
}

- (void)talkToAgentButtonDidTapped:(TTLFaqModel *)faqModel currentShownNavigationController:(UINavigationController *)navigationController {
    // User taps the Talk to Agent button in home or FAQ details page
    // Implementing this will prevent opening the create new case form by default
}

- (void)faq:(TTLFaqModel *)faqModel contentUrlDidTapped:(NSURL *)url currentShownNavigationController:(UINavigationController *)navigationController {
    // User taps a url in FAQ content
}

- (void)faq:(TTLFaqModel *)faqModel contentUrlDidLongPressed:(NSURL *)url currentShownNavigationController:(UINavigationController *)navigationController {
    // User long presses a url in FAQ content
}

- (void)faq:(TTLFaqModel *)faqModel contentEmailAddressDidTapped:(NSURL *)emailAddress currentShownNavigationController:(UINavigationController *)navigationController {
    // User taps an email address in FAQ content
}

- (void)faq:(TTLFaqModel *)faqModel contentEmailAddressDidLongPressed:(NSURL *)emailAddress currentShownNavigationController:(UINavigationController *)navigationController {
    // User long presses an email address in FAQ content
}

- (void)faq:(TTLFaqModel *)faqModel contentPhoneNumberDidTapped:(NSURL *)phoneNumber currentShownNavigationController:(UINavigationController *)navigationController {
    // User taps a phone number in FAQ content
}

- (void)faq:(TTLFaqModel *)faqModel contentPhoneNumberDidLongPressed:(NSURL *)phoneNumber currentShownNavigationController:(UINavigationController *)navigationController {
    // User long presses a phone number in FAQ content
}
  
@end
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}

```swift
import OneTalkLiveChat

class ViewController: UIViewController, TapTalkLiveDelegate {
    
    override func viewDidLoad() {
        // Set TapTalkLive delegate to current view controller
        TapTalkLive.sharedInstance().delegate = self
    }
    
    // MARK: TapTalkLiveDelegate
    
    func didTappedCloseButtonInHomePageView(withCurrentShownNavigationController navigationController: UINavigationController?) {
        // User taps close button in home page
    }
    
    func didTappedCloseButtonInCreateCaseView(withCurrentShownNavigationController navigationController: UINavigationController?) {
        // User taps close button in create case form
    }
    
    func didTappedCloseButtonInCaseListView(withCurrentShownNavigationController navigationController: UINavigationController?) {
        // User taps close button in case list page
    }
    
    func seeAllMessagesButtonDidTapped(withCurrentShownNavigationController navigationController: UINavigationController?) {
        // User taps the See All Messages button in home page
        // Implementing this will prevent opening the case list page by default
    }
    
    func createNewMessageButtonDidTapped(withCurrentShownNavigationController navigationController: UINavigationController?) {
        // User taps the New Messages button in home or case list page
        // Implementing this will prevent opening the create new case form by default
    }
    
    func caseListItemDidTapped(withCurrentShownNavigationController navigationController: UINavigationController?, lastMessage: TAPMessageModel?) {
        // User taps a case from a list in home or case list page
        // Implementing this will prevent opening the selected chat room by default
    }
    
    func faqChildDidTapped(_ faqModel: TTLFaqModel?, currentShownNavigationController navigationController: UINavigationController?) {
        // User taps a FAQ from a list in home or FAQ details page
        // Implementing this will prevent opening the selected FAQ details page by default
    }
    
    func closeButton(inFaqDetailsViewDidTapped faqModel: TTLFaqModel?, currentShownNavigationController navigationController: UINavigationController?) {
        // User closes the FAQ details page
    }
    
    func talk(toAgentButtonDidTapped faqModel: TTLFaqModel?, currentShownNavigationController navigationController: UINavigationController?) {
        // User taps the Talk to Agent button in home or FAQ details page
        // Implementing this will prevent opening the create new case form by default
    }
    
    func faq(_ faqModel: TTLFaqModel?, contentUrlDidTapped url: URL?, currentShownNavigationController navigationController: UINavigationController?) {
        // User taps a url in FAQ content
    }
    
    func faq(_ faqModel: TTLFaqModel?, contentUrlDidLongPressed url: URL?, currentShownNavigationController navigationController: UINavigationController?) {
        // User long presses a url in FAQ content
    }
    
    func faq(_ faqModel: TTLFaqModel?, contentEmailAddressDidTapped emailAddress: URL?, currentShownNavigationController navigationController: UINavigationController?) {
        // User taps an email address in FAQ content
    }
    
    func faq(_ faqModel: TTLFaqModel?, contentEmailAddressDidLongPressed emailAddress: URL?, currentShownNavigationController navigationController: UINavigationController?) {
        // User long presses an email address in FAQ content
    }
    
    func faq(_ faqModel: TTLFaqModel?, contentPhoneNumberDidTapped phoneNumber: URL?, currentShownNavigationController navigationController: UINavigationController?) {
        // User taps a phone number in FAQ content
    }
    
    func faq(_ faqModel: TTLFaqModel?, contentPhoneNumberDidLongPressed phoneNumber: URL?, currentShownNavigationController navigationController: UINavigationController?) {
        // User long presses a phone number in FAQ content
    }
}
```

{% endtab %}
{% endtabs %}

| **Method Name**                                                                                    | **Invoked When**                                                                                                                                                      |
| -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`didTappedCloseButtonInHomePageViewWithCurrentShownNavigationController:`**                      | User closes the home page. Returns the currently shown **navigation controller**.                                                                                     |
| **`didTappedCloseButtonInCreateCaseViewWithCurrentShownNavigationController:`**                    | User closes the create case form page. Returns the currently shown **navigation controller**.                                                                         |
| **`didTappedCloseButtonInCaseListViewWithCurrentShownNavigationController:`**                      | User closes the case list page. Returns the currently shown **navigation controller**.                                                                                |
| **`seeAllMessagesButtonDidTappedWithCurrentShownNavigationController:`**                           | User taps the See All Messages button in home page. Returns the currently shown **navigation controller**.                                                            |
| **`createNewMessageButtonDidTappedWithCurrentShownNavigationController:`**                         | User taps the New Messages button in home or case list page. Returns the currently shown **navigation controller**.                                                   |
| **`caseListItemDidTappedWithCurrentShownNavigationController:lastMessage:`**                       | User taps a case from a list in home or case list page. Returns the currently shown **navigation controller** and selected case's **last message**.                   |
| **`faqChildDidTapped:currentShownNavigationController:`**                                          | User taps a FAQ from a list in home or FAQ details page. Returns the selected **FAQ Model** and currently shown **navigation controller**.                            |
| **`closeButtonInFaqDetailsViewDidTapped:currentShownNavigationController:`**                       | User closes the FAQ details page. Returns the selected **FAQ Model** and currently shown **navigation controller**.                                                   |
| **`talkToAgentButtonDidTapped:currentShownNavigationController:`**                                 | User taps the Talk to Agent button in home or FAQ details page. Returns the selected **FAQ Model** and currently shown **navigation controller**.                     |
| **`faq:contentUrlDidTapped:currentShownNavigationController:navigationController:`**               | User taps a url in FAQ content. Returns the currently shown **navigation controller**, selected **FAQ Model**, and the selected **url**.                              |
| **`faq:contentUrlDidLongPressed:currentShownNavigationController:navigationController:`**          | User long presses a url in FAQ content. Returns the currently shown **navigation controller**, selected **FAQ Model**, and the selected **url**.                      |
| **`faq:contentEmailAddressDidTapped:currentShownNavigationController:navigationController:`**      | User taps an email address in FAQ content. Returns the currently shown **navigation controller**, selected **FAQ Model**, and the selected **email address**.         |
| **`faq:contentEmailAddressDidLongPressed:currentShownNavigationController:navigationController:`** | User long presses an email address in FAQ content. Returns the currently shown **navigation controller**, selected **FAQ Model**, and the selected **email address**. |
| **`faq:contentPhoneNumberDidTapped:currentShownNavigationController:navigationController:`**       | User taps a phone number in FAQ content. Returns the currently shown **navigation controller**, selected **FAQ Model**, and the selected **phone number**.            |
| **`faq:contentPhoneNumberDidLongPressed:currentShownNavigationController:navigationController:`**  | User long presses a phone number in FAQ content. Returns the currently shown **navigation controller**, selected **FAQ Model**, and the selected **phone number**.    |
