Firebase support
Learn how to use the AppKickstarter Firebase in a multi-platform project for authentication and data transfer objects management.
This documentation outlines the usage of Firebase wrapper in a multi-platform project that supports both Android and iOS platforms. The Firebase module is defined using Koin and provides a set of authentication functions through the KickstarterAuth interface, which can be called by both platforms. Additionally, the KickstarterFirebaseFirestore class provides methods to perform CRUD operations on data transfer objects.
Initialization
Firebase is set up as the default initialization in AppKickstarter. However, the project is designed to allow for the possibility of plugging in other backends like Supabase, Ktor, and others.
To initialize Firebase in the Android project, Koin is used along with the initFirebase function:
initFirebase(this)
initKoin {
modules(
listOf(
module { androidContext(this@KickstarterApplication) },
androidAppModule,
firebaseModule
)
)
}The firebaseModule is defined as:
val firebaseModule = module {
single { Firebase.firestore }
single { Firebase.auth }
singleOf(::KickstarterFirebaseAuth).bind(KickstarterAuth::class)
singleOf(::KickstarterFirebaseFirestore).bind(KickstarterRemoteDB::class)
}Authentication
The KickstarterAuth interface defines all the possible actions of the backend responsible for authentication. These actions include :
Data transfer objects
The KickstarterFirebaseFirestore class provides methods to perform CRUD operations on data transfer objects. For example, the uploadPost(post: Post) function allows creating or updating a post. It uses the PostDto class to handle data transfer objects. The getAllPosts() function fetches all the posts from the Firestore database.
Last updated
Was this helpful?