xcode – 从新的Firebase中检索数据

前端之家收集整理的这篇文章主要介绍了xcode – 从新的Firebase中检索数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
请帮忙.迁移到新的Firebase后,我无法检索数据.
使用这种结构:
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)")
    })
}

跑完后我看到错误

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:

我阅读了文档,但无法解决此问题.
GoogleService-Info.plist我添加到项目中.

解决方法

我还没有看到这个答案,我不得不将配置调用添加到AppDelegate init方法.所以它看起来像:
override init() {
    super.init()
    // Firebase Init
    FIRApp.configure()
}

猜你在找的iOS相关文章