-
-
Notifications
You must be signed in to change notification settings - Fork 180
KMP first time using firebase-kotlin-sdk #716
mylockerbiz
started this conversation in
General
-
i have a project with android, desktop and wasm. I am trying to implement firebase-kotlin-sdk.
the common code in App.kt fails when calling Firebase.initialize(Application(), options) because the context requirement is missing or not yet available. Is there a sample project or example code that works for all the platforms that shows the Application/Context object comes from?
class OWJFireBase {
lateinit var firebaseApp: FirebaseApp
fun initializeFirebase() {
val options = initFireBaseOptions()
firebaseApp = Firebase.initialize(???? as Any, options)
}
fun initFireBaseOptions(): FirebaseOptions {
return FirebaseOptions(
........ load the values
)
}
}
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
You'll need to decide for yourself how to deal with the context.
For example, I have an AppContext class that I use in various places throughout my app.
// Common module expect class AppContext { fun getApplicationContext(): Any? } // Android module actual class AppContext(val context: Application) { actual fun getApplicationContext(): Any? = context } // iOS module actual class AppContext { actual fun getApplicationContext(): Any? = null }
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment