Ios 如何修复用于Firebase通知的AppDelegate中使用的此弃用代码?

Ios 如何修复用于Firebase通知的AppDelegate中使用的此弃用代码?,ios,swift,firebase,Ios,Swift,Firebase,以下在iOS 10中被弃用的代码如何在Swift 4中使用?此应用程序用于使用Firebase发送推送通知 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after applic

以下在iOS 10中被弃用的代码如何在Swift 4中使用?此应用程序用于使用Firebase发送推送通知

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    let notificationTypes : UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound]
    let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)

    application.registerForRemoteNotifications()
    application.registerUserNotificationSettings(notificationSettings)


    return true
}


非常感谢您的帮助。

这是我现在在使用Firebase通知的应用程序中所做的

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    if #available(iOS 10.0, *) {
      // For iOS 10 display notification (sent via APNS)
      UNUserNotificationCenter.current().delegate = self

      let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
      UNUserNotificationCenter.current().requestAuthorization(
          options: authOptions,
          completionHandler: {_, _ in })

      // For iOS 10 data message (sent via FCM)
      Messaging.messaging().remoteMessageDelegate = self

    } else {
      let settings: UIUserNotificationSettings =
          UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
      application.registerUserNotificationSettings(settings)
    }

    application.registerForRemoteNotifications()

    FirebaseApp.configure()

}

可能重复的请参阅重复链接的第二个答案…尝试此选项
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    if #available(iOS 10.0, *) {
      // For iOS 10 display notification (sent via APNS)
      UNUserNotificationCenter.current().delegate = self

      let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
      UNUserNotificationCenter.current().requestAuthorization(
          options: authOptions,
          completionHandler: {_, _ in })

      // For iOS 10 data message (sent via FCM)
      Messaging.messaging().remoteMessageDelegate = self

    } else {
      let settings: UIUserNotificationSettings =
          UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
      application.registerUserNotificationSettings(settings)
    }

    application.registerForRemoteNotifications()

    FirebaseApp.configure()

}