Documentation #253
-
Is there any documentation for this project? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
It's super confusing. The library seems to be alive but there is absolutely no documentation and examples. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to use it but no documentation |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I finished an article talking about the implementation in Android and iOS https://medium.com/@carlosgub/how-to-implement-firebase-firestore-in-kotlin-multiplatform-mobile-with-compose-multiplatform-32b66cdba9f7 |
Beta Was this translation helpful? Give feedback.
-
All you need to know, you can use official documentation for general behaviour. There are no major differences, except that firebase kotlin makes life easier (in the asynchronous context) by using suspendable methods (so no more callbacks -- I'm from Android world, I used a bit firebase in JS/Typescript but I don't remember how it works). The main difference is how you have to initialise the Firebase App. For android
import dev.gitlive.firebase.Firebase
... other imports
class AndroidApplication : Application() {
override fun onCreate() {
super.onCreate()
Firebase.initialize(context = this)
}
} note: this method has multiple overloads and you can see that For JS val firebaseConfig = FirebaseOptions(
applicationId = "1:95***********",
apiKey = "AIz***********",
gaTrackingId = "G-***********",
storageBucket = "***********.appspot.com",
projectId = "***********-*****",
gcmSenderId = "9***********2",
authDomain = "***********-******.firebaseapp.com",
)
fun main(){
Firebase.initialize(options = options)
} Going further class InitialiseFirebase {
operator fun invoke(host: String, options: FirebaseOptions? = null, context: Any? = null) {
if (options != null) {
Firebase.initialize(options = options, context = context)
} else {
Firebase.initialize(context = context)
}
Firebase.auth.useEmulator(host, 9099)
Firebase.firestore.useEmulator(host, 8080)
}
} So I'm free to pass or the options if I'm in JS, or the android context... I didn't try for ios tho. For the WASM, it's going to be the same as JS, but I need to motivate myself to port firebase kotlin to WASM 😪 Oh yes, why did I choose to pass a required Best regards, Thaerith |
Beta Was this translation helpful? Give feedback.
All you need to know, you can use official documentation for general behaviour. There are no major differences, except that firebase kotlin makes life easier (in the asynchronous context) by using suspendable methods (so no more callbacks -- I'm from Android world, I used a bit firebase in JS/Typescript but I don't remember how it works).
The main difference is how you have to initialise the Firebase App.
For android
google-services.json
where official documentation required it (next tobuild.gradle.kts
in you app module -- yes yes, even if your module is a KMP module, it doesn't matter).