Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 570
Dmitry Kuzin Avatar asked May 19 '16 07:05

Dmitry Kuzin


1 Answers

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() {
    super.init()
    // Firebase Init
    FIRApp.configure()
}
like image 101
0xT0mT0m Avatar answered Nov 06 '22 23:11

0xT0mT0m