Closed IvanSimovic closed 7 months ago
What platform/OS is your project running on? My Experience the first time was very tricky with this lib for integrate it on the Android Part and IOS Part
I am developing on macOs. Building the KMP library for android and iOS
Hi, I create a medium article about this https://medium.com/@carlosgub/how-to-implement-firebase-firestore-in-kotlin-multiplatform-mobile-with-compose-multiplatform-32b66cdba9f7 , you need to have something like this in your ios file
import SwiftUI
import Firebase // Add this line
@main
struct iOSApp: App {
// Add this init with the FirebaseApp.configure()
init(){
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
How does one initialize the app on a JVM target?
I have iOS + Android integration working, but looking at the instructions here, https://github.com/GitLiveApp/firebase-java-sdk#initializing-the-sdk, it isn't clear how to initialize the app on JVM targets.
Edit:
Okay, I now see the part in the above sdk: we include a minimal Android emulation layer in the SDK only implementing the functionality used by the Firebase libraries at runtime
. So I am just using the 'emulated' context.
val options = FirebaseOptions.Builder()
.setProjectId("my-firebase-project")
.setApplicationId("appId")
.setApiKey("apiKey")
// setDatabaseURL(...)
// setStorageBucket(...)
.build()
FirebaseApp.initializeApp(Context(), options)
Closing as it seems the issues are resolved
How do I initialize the app? I get this error message:
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.bambuser.onetoone.dev. Make sure to call FirebaseApp.initializeApp(Context) first.
the initializeApp function does not seem to be available. Also, context is not available in the SDK either. Dependencies I use are: implementation("dev.gitlive:firebase-auth:1.8.0"), implementation("dev.gitlive:firebase-firestore:1.8.0"), implementation("dev.gitlive:firebase-functions:1.8.0")
How the code looks with normal firebase:
Additional questions: Are there any example projects using this library? Can I have two firebase apps at the same time, one in my core app and one in the KMP library, both authenticated to same credentials?