Library events - infobip/mobile-messaging-sdk-ios GitHub Wiki
Library informs you about following events using NSNotificationCenter:
Notification name | Description |
---|---|
MMNotificationRegistrationUpdated |
Posted when the registration is updated on backend server. The notification is posted during the registration process, after a current APNs device token is stored on the server and the new Push Registration Id for the current user is generated. The userInfo dictionary contains the following keys: MMNotificationKeyRegistrationInternalId - contains a Push Registration Id string for the registered user. |
MMNotificationDeliveryReportSent |
Posted when the library has succesfully sent message delivery report. The userInfo dictionary contains the following keys: MMNotificationKeyDLRMessageIDs - contains a an array of message ID strings. |
MMNotificationAPIError |
Posted when a server error received. The notifications is posted during communication with the server, after an error occured. The userInfo dictionary contains the following keys: MMNotificationKeyAPIErrorUserInfo - contains a corresponding NSError object. |
MMNotificationMessageReceived |
Posted when a message is received. The notification is posted during handling of a new message that is either pushed by APNs or fetched from the server. The userInfo dictionary contains the following keys: MMNotificationKeyMessage - contains an object of MM_MTMessage class, that provides all message attributes. Deprecated keys: MMNotificationKeyMessagePayload - contains a remote notification payload; MMNotificationKeyMessageIsPush - contains a flag that indicates whether the message is pushed by APNs or pulled from the server; MMNotificationKeyMessageIsSilent - contains a flag that indicates whether the remote notification is a silent push. |
MMNotificationMessageTapped |
Posted when user opens the app by tapping on the notification alert. The userInfo dictionary contains the following key: MMNotificationKeyMessage - contains an object of MM_MTMessage class, that provides all message attributes. |
MMNotificationMessagesWillSend |
Posted when the mobile originated message is about to send to the server. The userInfo dictionary contains the following key: MMNotificationKeyMessageSendingMOMessages - contains an array of MM_MOMessage objects. |
MMNotificationMessagesDidSend |
Posted when the mobile originated message sent to the server. The userInfo dictionary contains the following key: MMNotificationKeyMessageSendingMOMessages - contains an array of MM_MOMessage objects. |
MMNotificationActionTapped |
Posted after the User tapped notification action button. The userInfo dictionary contains the following keys: MMNotificationKeyMessage - contains an object of MM_MTMessage class, that provides all message attributes, MMNotificationKeyActionIdentifier - contains an action identifier string, MMNotificationKeyNotificationUserInfo - contains an original notification userInfo. |
MMNotificationUserSynced |
Posted when the user data is saved on the server. |
MMNotificationInstallationSynced |
Posted after the installation data is saved on the server. |
MMNotificationPersonalized |
Posted after the current installation personalized with user profile |
MMNotificationDepersonalized |
Posted after the current installation depersonalized with user profile |
MMNotificationCenterAuthRequestFinished |
Posted after the Notification Center authorization request finished. The userInfo dictionary contains the following keys: MMNotificationKeyGranted - contains boolean, MMNotificationKeyError - optional error. |
MMNotificationInAppChatUnreadMessagesCounterUpdated |
Posted after the in-app chat receives a new message while not presented (increasing the counter of unread messages), or the count is reset to zero. The userInfo dictionary contains the following key: MMNotificationKeyInAppChatUnreadMessagesCounter - which is an integer value. |
MMNotificationInAppChatAvailabilityUpdated |
Posted after the in-app chat availability status received from backend server. The userInfo dictionary contains the following key: MMNotificationKeyInAppChatEnabled - contains boolean value. |
MMNotificationInAppChatViewChanged |
Posted after the in-app chat view has changed. The userInfo dictionary contains the following key: MMNotificationKeyInAppChatViewChanged - contains string value; all possible constants are described in MMChatWebViewState |
Notice
Following Geofencing events and not supported from SDK version 12.19.0 onwards.
Notification name | Description |
---|---|
MMNotificationGeographicalRegionDidEnter |
Posted when the user enters monitored region. The userInfo dictionary contains the following key: MMNotificationKeyGeographicalRegion - contains MMRegion object in which user entered. |
MMNotificationGeographicalRegionDidExit |
Posted when the user exits monitored region. The userInfo dictionary contains the following key: MMNotificationKeyGeographicalRegion - contains MMRegion object from which user exited. |
Examples
MMNotificationMessageReceived
-
Subscribe to notification:
//Objective-C [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(handleNewMessageReceivedNotification:) name: MMNotificationMessageReceived object: nil];
//Swift NotificationCenter.default.addObserver(self, selector: #selector(self.handleNewMessageReceivedNotification(_:)), name: NSNotification.Name(rawValue: MMNotificationMessageReceived), object: nil)
-
Handle the notifications:
//Objective-C -(void)handleNewMessageReceivedNotification:(NSNotification *)notification { id messagePayload = notification.userInfo[MMNotificationKeyMessage]; if ([messagePayload isKindOfClass:[MM_MTMessage class]]) { MM_MTMessage * message = messagePayload; //put here your code NSLog(@"%@", message.text); } }
//Swift @objc func handleNewMessageReceivedNotification(_ notification: NSNotification) { guard let userInfo = notification.userInfo, let message = userInfo[MMNotificationKeyMessage] as? MM_MTMessage else { return } //put here your code }