【问题标题】:New Firebase: Changing Database URL dynamically新 Firebase:动态更改数据库 URL
【发布时间】:2016-05-27 21:16:48
【问题描述】:

在旧的 Firebase 中,我曾经能够在运行时动态获取对不同数据库的引用(例如,在 dev 和 prod db 之间切换,甚至切换到用户定义的数据库 URL),因为传递了数据库 URL实例化数据库引用时作为字符串输入。

在新的 Firebase 中,数据库 URL(以及其他设置)位于 GoogleService-Info.plist 中。

我以前的方法还能做吗?还是有其他推荐的方法来实现这一目标?

【问题讨论】:

  • 我没有切换到新的 Firebase,动态 URL 有问题。您如何设法添加事件侦听器,例如在不同用户的动态 URL 上添加 child_added?卡住了:|

标签: ios swift firebase


【解决方案1】:

好吧,我还是找到了答案。您必须像这样手动初始化应用程序,而不是通常的设置:

let firOptions = FIROptions(googleAppID: googleAppID, bundleID: bundleID, GCMSenderID: GCMSenderID, APIKey: nil, clientID: nil, trackingID: nil, androidClientID: nil, databaseURL: databaseURL, storageBucket: nil, deepLinkURLScheme: nil)        
FIRApp.configureWithOptions(firOptions)

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

你也可以用configureWithName:options:命名它们

更多文档:https://firebase.google.com/docs/reference/ios/firebaseanalytics/interface_f_i_r_app

【讨论】:

  • 你知道我在哪里可以找到更多信息吗?您提供的链接返回 404 错误。谢谢。
猜你喜欢
  • 1970-01-01
  • 2019-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-08
  • 2017-10-20
相关资源
最近更新 更多