Метод didReceiveRemoteNotification не работает - PullRequest
0 голосов
/ 08 мая 2020

Приложение полностью закрыто. Отправляю pu sh уведомление и нажимаю. Метод didReceiveRemoteNotification не работает. Я использовал iOS 13.5 beta 3

Я не мог понять, где я сделал ошибку.

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (didAllow, error) in
            DispatchQueue.main.async(execute: {
              UIApplication.shared.registerForRemoteNotifications()
            })
        }
        return true
    }



    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        print(deviceToken)
        let deviceTokenString : String = deviceToken.map{ String(format: "%02x", $0) }.joined().replacingOccurrences(of: "<", with: "").replacingOccurrences(of: ">", with: "").replacingOccurrences(of: " ", with: "");
        print("Got token data! \(deviceTokenString)")
    }

    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
            print(error.localizedDescription)
            print("Not registered notification")
    }


       func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
           print("didReceiveRemoteNotification fetchCompletionHandler userInfo \(userInfo)")
       }
{
   "aps":{
      "alert":{
         "body":"test media body",
         "title":"test media subject"
      },
      "badge":0,
      "sound":"smoke_on_the_water",
      "content-available":1,
      "mutable-content":1
   },
   "url":"",
   "mediaUrl":"https://mcdn01.gittigidiyor.net/ps/jenerikbanner_1573449864.jpg",
   "pushType":"Image",
   "pushId":"769a660b-9542-4ec0-b444-6fbf7e38697e",
   "altUrl":"",
   "sound":"smoke_on_the_water"
}

Capabilities

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...