从新的Firebase中检索数据 [英] Retrieve data from new Firebase

查看:134
本文介绍了从新的Firebase中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮忙迁移到新的Firebase后,我无法检索数据。
使用这个结构:

$ p $ let ref = FIRDatabase.database()。reference()

重写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]默认应用尚未配置。 
2016-05-19 10:04:22.276 123a [88652:13688922] ***终止应用程序由于未捕获的异常'MissingDatabaseURL',原因:'无法获得FIRDatabase实例:FIRApp对象的FirebaseOptions中没有databaseURL对象'
***第一次抛出调用堆栈:

解决这个问题。
GoogleService-Info.plist我添加到项目中。

解决方案

我还没有看到这个答案,将配置调用添加到AppDelegate init方法。所以它看起来像:

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


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.

解决方案

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()
}

这篇关于从新的Firebase中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆