ios - 尝试设置 Firebase 推送通知时出现错误

标签 ios swift firebase push-notification

我正在关注 Firebase 推送通知快速入门,但收到此错误。

enter image description here

不确定发生了什么,因为这是快速入门指南的文档。

最佳答案

您正在尝试将 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/

相关文章:

iOS 如何使用两个固定部分和一个动态表格 View 进行布局?

ios - Swift 中 UIImage 的淡入淡出动画

javascript - 我无法通过在 IOS 上将 authWithOAuthRedirect 与 Chrome 一起使用来获取 authData

ios - CAShapeLayer 没有动画

ios - JSON 没有快速更新

ios - 无法从我的 for 循环中向 NSmutableArray 添加超过 260 个元素的元素

swift - 在 queryForTable() 中解析查询多键 swift

IF 条件错误中的 Swift3 选项链接?

android - Recyclerview 不显示来自 Firebase Kotlin 的数据

javascript - Firestore 分页 - 以前