# iOS Notifications 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 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 bNotificationUserUpdated @"bNUserUpdated" #define bNotificationUserUpdated_PUser @"bNUserUpdated_PUser" #define bNotificationThreadRead @"bNThreadRead" #define bNotificationBadgeUpdated @"bNBadgeUpdated" #define bNotificationPresentChatView @"bNPresentChatView" #define bNotificationPresentChatView_PThread @"bNPresentChatView_PThread" #define bNotificationThreadUsersUpdated @"bNThreadUsersUpdated" #define bNotificationThreadMetaUpdated @"bNThreadMetaUpdated" #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 }); }] ```