升级到 Xcode 12.5 后,我的项目将无法构建,并且我的 AppDelegate 中出现错误。我可以确认在升级之前没有任何问题,而且我在任何地方都找不到解决此问题的文档。先感谢您!
AppDelegate 代码:
import UIKit
import Firebase
import IQKeyboardManagerSwift
import FirebaseMessaging
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
let gcmMessageIDKey = "gcm.message_id"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
IQKeyboardManager.shared.enable = true
Messaging.messaging().delegate = self
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
print(userInfo)
completionHandler(UIBackgroundFetchResult.newData)
}
return true
}
}
错误:
1)
application.registerUserNotificationSettings(settings)
“'(UIApplication, [AnyHashable: Any], @escaping (UIBackgroundFetchResult) -> Void) -> ()' 类型的值没有成员 'registerUserNotificationSettings'”
2)
application.registerForRemoteNotifications()
“'(UIApplication, [AnyHashable: Any], @escaping (UIBackgroundFetchResult) -> Void) -> ()' 类型的值没有成员 'registerForRemoteNotifications'”