调用FIRApp.configure()后未配置iOS Firebase应用程序

时间:2016-09-16 14:47:10

标签: ios firebase firebase-realtime-database

我有一个iOS(Swift)应用程序,AppDelegate中包含以下代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  FIRApp.configure()
  FIRDatabase.database().persistenceEnabled = true
  return true
}

该应用在persistenceEnabled = true行崩溃,异常FIRAppNotConfigured,消息"Failed to get default FIRDatabase instance. Must call FIRApp.configure() before using FIRDatabase."

显然,我在此之前就已经调用FIRApp.configure(),因此建议的解决方案不正确。调用它时,日志输出甚至会显示"Configuring the default app"

问题可能是什么,我如何解决它以便我可以使用FIRDatabase?

1 个答案:

答案 0 :(得分:9)

尝试:

override init() {
   // Firebase Init
   FIRApp.configure()
}