Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

KMP first time using firebase-kotlin-sdk #716

mylockerbiz started this conversation in General
Discussion options

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
 )
 }
}
You must be logged in to vote

Replies: 1 comment

Comment options

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
}
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /