最佳答案
您正在尝试将 AppDelegate
设置为 UNUserNotificationCenterDelegate
,但您的 AppDelegate
尚未实现该协议(protocol)。了解有关协议(protocol)的更多信息 here 。可以找到 UNUserNotificationCenterDelegate
的规范 here 。像这样的事情会起作用:
extension AppDelegate: UNUserNotificationCenterDelegate {
optional func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// TODO: Implement
}
optional func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
// TODO: Implement
}
}
第二个错误表示该属性不存在。该文档很可能与框架已经过时。
关于ios - 尝试设置 Firebase 推送通知时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40315263/