# Events

Notifications happen whenever data on the server changes and needs to update the client. Primarily there are two types of notifications that come through:

1. Hooks - custom event manager
2. Events - NotificationCenter&#x20;

We are transitioning from using the notification center a custom notification system.

#### Hooks

You can find a list of the hook events available in the `PHookHandler.h` file:

```
#define bHookDidAuthenticate @"bHookDidAuthenticate"

#define bHook_AuthenticationType @"bHook_AuthenticationType"
#define bHook_AuthenticationTypeLogin @"login"
#define bHook_AuthenticationTypeSignUp @"signup"
#define bHook_AuthenticationTypeCached @"cached"

#define bHookWillLogout @"bHookWillLogout"
#define bHookDidLogout @"bHookDidLogout"

#define bHookUserOn @"bHookUserOn"

#define bHookContactWillBeAdded @"bHookContactWillBeAdded"
#define bHookContactWasAdded @"bHookContactWasAdded"
#define bHookContactWillBeDeleted @"bHookContactWillBeDeleted"
#define bHookContactWasDeleted @"bHookContactWasDeleted"

#define bHookMessageRecieved @"bHookMessageRecieved"

#define bHookMessageWillSend @"bHookMessageWillSend"
#define bHookMessageSending @"bHookMessageSending"
#define bHookMessageDidSend @"bHookMessageDidSend"
#define bHookMessageWillUpload @"bHookMessageWillUpload"
#define bHookMessageDidUpload @"bHookMessageDidUpload"

#define bHookMessageWillBeDeleted @"bHookMessageWillBeDeleted"
#define bHookMessageWasDeleted @"bHookMessageWasDeleted"

#define bHookThreadAdded @"bHookThreadAdded"
#define bHookThreadRemoved @"bHookThreadRemoved"

#define bHook_PMessage @"bHook_PMessage"
#define bHook_PUser @"bHook_PUser"
#define bHook_PThread @"bHook_PThread"

#define bHookInternetConnectivityDidChange @"bHookInternetConnectivityDidChange"
#define bHookUserWillDisconnect @"bHookUserWillDisconnect"
```

You can use the hook like this:

```
[BChatSDK.hook addHook:[BHook hook:^(NSDictionary * dict) {
        id<PMessage> messageModel = dict[bHook_PMessage];


}] withNames: @[bHookMessageRecieved]];
```

#### Events

You can find a list of events in the `PNetworkAdater.h` file. Here is a list:

```
#define bNotificationLogout @"bNLogout"

#define bNotificationMessageUpdated @"bNMessageUpdated"
#define bNotificationMessageUpdatedKeyMessage @"bNMessageUpdatedKeyMessage"

#define bNotificationFlaggedMessageAdded @"bNFlaggedMessageAdded"
#define bNotificationFlaggedMessageAdded_PMessage @"bNFlaggedMessageAdded_PMessage"

#define bNotificationFlaggedMessageRemoved @"bNFlaggedMessageRemoved"
#define bNotificationFlaggedMessageRemoved_PMessage @"bNFlaggedMessageRemoved_PMessage"

#define bNotificationThreadRead @"bNThreadRead"
#define bNotificationBadgeUpdated @"bNBadgeUpdated"

#define bNotificationPresentChatView @"bNPresentChatView"
#define bNotificationPresentChatView_PThread @"bNPresentChatView_PThread"

#define bNotificationThreadLastMessageUpdated @"bNThreadLastMessageUpdated"
#define bNotificationThreadLastMessageUpdated_Text @"bNThreadLastMessageUpdated_Text"

#define bNotificationReadReceiptUpdated @"bNReadReceiptUpdated"
#define bNotificationReadReceiptUpdatedKeyMessage @"bNReadReceiptUpdatedKeyMessage"

#define bNotificationTypingStateChanged @"bNTypingStateChanged"
#define bNotificationTypingStateChangedKeyThread @"bNTypingStateChangedKeyThread"
#define bNotificationTypingStateChangedKeyMessage @"bNTypingStateChangedKeyMessage"

#define bNotificationAuthenticationComplete @"bNAuthenticationComplete"
```

You can listen for an event like this:

```
[[NSNotificationCenter defaultCenter] addObserverForName:bNotificationThreadUsersUpdated
                                                                     object:Nil
                                                                      queue:Nil
                                                                 usingBlock:^(NSNotification * notification) {
                                                                     dispatch_async(dispatch_get_main_queue(), ^{
                 // Handle here                                                                                                              });
}]
```


---

# 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://chat-sdk.gitbook.io/ios/api/events.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.
