I got 'Must call FIRApp.configure() before using FIRDatabase' error even though I already called it in the 'Appdelegate.swift'.This is my app delegate
First Solution:
If you use FIRDatabase.database().reference()
in your ViewController, please share the code with us. If you use something like this:
var db = FIRDatabase.database().reference()
before viewDidLoad, you can get this error. Better make this:
var db: FIRDatabaseReference!
override func viewDidLoad() {
super.viewDidLoad()
db = FIRDatabase.database().reference()
}
In this way, even if configure() is in finishLaunchingWithOptions, the app won't crash.
Second solution:
In AppDelegate.swift
just add this lines of code:
override init() {
FirebaseApp.configure()
FIRDatabase.database().persistenceEnabled = true
}
When the app launch, it will go to init()
method and will configure FireBase before everything else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With