Кузин Дмитрий Кузин Дмитрий - 4 months ago 18
Swift Question

Retrieve data from new Firebase

Please help. After migrating to new Firebase I can't retrieve data.
Use this construction:

let ref = FIRDatabase.database().reference()

override func viewDidLoad() {
super.viewDidLoad()
ref.observeEventType(FIRDataEventType.Value, withBlock: { (snapshot) in
let postDict = snapshot.value as! [String : AnyObject]
print("\(postDict)")
})
}


After running I see error:

2016-05-19 10:04:22.264 123a[88652:13688922] The default app has not been configured yet.
2016-05-19 10:04:22.276 123a[88652:13688922] *** Terminating app due to uncaught exception 'MissingDatabaseURL', reason: 'Failed to get FIRDatabase instance: FIRApp object has no databaseURL in its FirebaseOptions object.'
*** First throw call stack:


I read documentation, but can't resolve this problem.
GoogleService-Info.plist I add to project.

Answer

I didn't see this answer yet, I had to add the configure call to the AppDelegate init method. So it looks like:

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