Can you help me please? App receives push notifications and inside of every push payload it has url. Every time when app is launched and in background mode after tapping on push notification this url always opens. But if app is not active after tapping there is only open app without open url. Maybe someone has already struggled with this problem.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
guard isFromoLogout == false else {
UIApplication.shared.applicationIconBadgeNumber = 0
isFromoLogout = false
return
}
// From server
let jsonMap = Map(mappingType: .fromJSON, JSON: response.notification.request.content.userInfo["aps"] as! [String : Any])
if let notificationModel = RPushNotificationModel(map: jsonMap), notificationModel.pushType == .openLink {
if let iosURL = notificationModel.iosURL,
let url = URL(string: iosURL),
UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
...