Handling Push Notification Taps
If you’re using the built-in push notification rendering provided by the Mindbox SDK, you need to override
userNotificationCenter(_:didReceive:withCompletionHandler:) in AppDelegate to handle notification taps.
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
if let pushModel = Mindbox.shared.getMindboxPushData(userInfo: response.notification.request.content.userInfo), Mindbox.shared.isMindboxPush(userInfo: response.notification.request.content.userInfo) {
var url = ""
if let buttons = pushModel.buttons, let clickedButton = buttons.first(where: { $0.uniqueKey == response.actionIdentifier}), let buttonUrl = clickedButton.url {
url = buttonUrl
} else if let clickUrl = pushModel.clickUrl {
url = clickUrl
}
// Process the Click URL
handleUrl(url)
}
}Make sure to handle URLs on the app side. The SDK does not provide URL handling by default.
Updated 6 months ago

