使用 Firebase 在 Flutter (iOS) 上启动时应用程序关闭,不会出现任何错误

问题描述

该应用程序在 android 上运行良好,但是,当我在 iOS 上打开该应用程序时,它立即崩溃而没有出现任何错误

解决方法

我只是通过移动到函数顶部的行下方来解决这个问题。

FirebaseApp.configure()

将上述行作为 didFinishLaunchingWithOptions 方法中的第一条指令。如下图。

override func application(
    _ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application,didFinishLaunchingWithOptions: launchOptions)
  }