Reputation: 1374
I have been searching the web and gone through all tutorials I found about this subject, read the API reference but ultimately couldn't find any solution to my simple requirement.
In iOS / Swift, one has to install a "GoogleService-Info.plist" in the xCode project and then call FIRApp.configure()
in the AppDelegate in order to load the configuration from the aforementioned plist file.
That all works perfectly, but what I would like now is being able to retrieve the parameters from this plist, to be more precise the database URL, so that I don't have to hardcode it anywhere (other than in that plist).
Of course I could use a dictionary to separately read the plist and retrieve the database url, but I would have expected to access the FIRApp object and retrieve it from there...
Did I miss something or is that option not given to retrieve the Firebase Parameters / Options directly from the FIRApp Object?
Upvotes: 1
Views: 2379
Reputation: 3776
I use a very simple extension (Swift 4):
extension Database {
var url: URL? {
let refAsString = "\(FirebaseDatabase.Database.database().reference())"
return URL(string: refAsString)
}
}
Upvotes: 0
Reputation: 5736
You can use FIRDatabase.database().reference()
to get a reference to your database that was loaded via FIRApp.configure()
.
Upvotes: 3