新的Firebase:动态更改数据库URL [英] New Firebase: Changing Database URL dynamically
问题描述
GoogleService-Info .plist
。 还有可能以旧的方式做我做的事吗?还是有另一种推荐的方式来实现呢?
好吧,无论如何我找到了答案。
let firOptions = FIROptions(googleAppID:googleAppID),而不是通常的设置,您必须手动初始化应用程序,bundleID:bundleID,GCMSenderID:GCMSenderID,APIKey:nil,clientID:nil,trackingID:nil,androidClientID:nil,databaseURL:databaseURL,storageBucket:nil,deepLinkURLScheme:nil)$ b $ FIRApp.configureWithOptions(firOptions)
let firebaseRef = FIRDatabase.database()。reference()
有关 configureWithName:options:
的进一步文档: https://firebase.google.com/docs/reference/ios/firebaseanalytics/interface_f_i_r_app
In the old Firebase, I used to be able to get reference to different database dynamically at run time (say, switching between dev and prod db, or even switching to a user-defined database URL) because the database URL is passed in as a string when instantiating a db reference.
In the new Firebase, the database URL (along with other settings) live inside GoogleService-Info.plist
.
Is it still possible to do what I did in the old way? Or is there another recommended way to achieve that?
Well, I found the answer anyway. Instead of the usual setup, you'll have to initialize the app manually like so:
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()
You can name them too with configureWithName:options:
Further documentation on this: https://firebase.google.com/docs/reference/ios/firebaseanalytics/interface_f_i_r_app
这篇关于新的Firebase:动态更改数据库URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!