这是 Firebase 文档中的代码。
if #available(iOS 10.0, *) {
let authOptions : UNAuthorizationOptions = [.Alert, .Badge, .Sound]
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions(
authOptions,
completionHandler: {_,_ in })
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.currentNotificationCenter().delegate = self
// For iOS 10 data message (sent via FCM)
FIRMessaging.messaging().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
我没有修改任何代码。但 Xcode 报错 "Use of undeclared type UNAuthorizationOptions
, UNUserNotificationCenter
, FIRMessagingDelegate
"
另外我还有一行代码。
NotificationCenter.defaultCenter.addObserver(self,selector: #selector(self.tokenRefreshNotification),name: kFIRInstanceIDTokenRefreshNotification,object: nil)
它说“类型AppDelegate的值没有成员tokenRefreshNotification
”。
我只是从Firebase文档中复制并粘贴了我的代码,但出现了错误!