How to handle a message when user opens the app by tapping on a notification alert? - infobip/mobile-messaging-sdk-ios GitHub Wiki
In order to handle user tap on notification alert:
-
Implement
MMMessageHandlingDelegate
protocol and it's methoddidPerform(action:forMessage:completion:)
, i.e.:class MyMessageHandlingDelegate : MMMessageHandlingDelegate { func didPerform(action: MMNotificationAction, forMessage message: MM_MTMessage?, notificationUserInfo: [String: Any]?, completion: @escaping () -> Void) { if action.isTapOnNotificationAlert { // here you check if the action is indeed a tap on alert print("Message with text: \(message.text) was tapped") } // don't forget to call `completion`, it's very important to tell the system that action handling is finished completion() } }
-
Pass the delegate object to MobileMessaging SDK:
MobileMessaging.messageHandlingDelegate = MyMessageHandlingDelegate()