Сбой приложения в iOS 12.0 - PullRequest
       8

Сбой приложения в iOS 12.0

0 голосов
/ 27 сентября 2018

Сбой приложения в iOS 12.0 до того, как iOS 12.0 работала должным образом, я его погуглил, но не нашел решения для журнала ниже.

Завершение работы приложения из-за необработанного исключения «NSUnknownKeyException»,Причина: '[setValue: forUndefinedKey:]: этот класс не соответствует значению ключа для кода

1 Ответ

0 голосов
/ 27 сентября 2018

В iOS12 shouldAlwaysAlertWhileAppIsForeground keyPath удален и больше не поддерживается.


Чтобы добиться этого на iOS12:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    UNUserNotificationCenter.current().delegate = self
    ...
}
...
extension AppDelegate: UNUserNotificationCenterDelegate {
    // The method will be called on the delegate only if the application is in the foreground. 
    // If the method is not implemented or the handler is not called in a timely manner then the notification will not be presented. 
    // The application can choose to have the notification presented as a sound, badge, alert and/or in the notification list. 
    //This decision should be based on whether the information in the notification is otherwise visible to the user.
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.alert, .sound])// Will present an alert and will play a sound when a notification arrives
    }
}
...