Метод didReceiveRemoteNotification не вызывается при поступлении уведомления - PullRequest
0 голосов
/ 24 августа 2018

Я не понимаю, почему мой код не работает.

мой код :

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

{

    print("User Info = ",userInfo)

    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadChatTableView"), object: nil)

    GlobalConstant.notificationDict = userInfo

    let notificationDictionary: NSDictionary = GlobalConstant.notificationDict?["aps"] as! NSDictionary

    let type: String = Global.getStringValue(notificationDictionary.value(forKey: "type") as AnyObject)

    //   application.applicationIconBadgeNumber = application.applicationIconBadgeNumber + 1

completionHandler(UIBackgroundFetchResult.noData)

var aps: [AnyHashable: Any] = userInfo["aps"] as! [AnyHashable : Any]

        //content.sound = UNNotificationSound.init(named: "tone.mp3")

        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)

        let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)

        UNUserNotificationCenter.current().add(request, withCompletionHandler: nil
}
...