0

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)
                }
            }
        }
...
denickman
  • 29
  • 4
  • Possible duplicate of [IOS notification when Application is closed](https://stackoverflow.com/questions/45057772/ios-notification-when-application-is-closed) – P.J Aug 13 '19 at 20:21
  • I would advice to include some code you tried into your question. It will increase the changes to get an answer and reduce the chances of having your question flagged and removed. – acarlstein Aug 13 '19 at 20:36

0 Answers0