The default app has not been configured yet

后端 未结 9 1629
予麋鹿
予麋鹿 2020-12-02 19:59

I\'m trying to upgrade my app to the new version of Firebase. I went through the setup guide and edited all of my code to match the new syntax. However, when I run the app,

9条回答
  •  没有蜡笔的小新
    2020-12-02 20:46

    The cleanest solution to me here is to have lazy properties in case you want to have the db on top of your file. So let's say you have a FirebaseService class where you want to have Firestore.firestore() db constant to use it in all of the functions in that class:

    private lazy var db = Firestore.firestore()
    

    Or if you are using Firebase Storage:

    private lazy var storage = Storage.storage().reference()
    

    Also keep in mind that if you are referencing the Database/Storage in init() of your classes, you still might have the same problem so avoid that.

提交回复
热议问题