FirebaseInstance

class FirebaseInstance : CoroutineScope

Provides methods to create and update documents from the Firebase project

  • https://firebase.google.com/docs/auth/android/google-signin

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
private val currUserId: String
Link copied to clipboard
private val db: FirebaseFirestore
Link copied to clipboard
private val fbAuth: FirebaseAuth
Link copied to clipboard
private val isUserLoggedIn: Boolean
Link copied to clipboard
private val topObjectsCollection: CollectionReference
Link copied to clipboard
private val topUsersCollection: CollectionReference
Link copied to clipboard
private val usersCollection: CollectionReference

Functions

Link copied to clipboard
private suspend fun createOrGetUser(fbUser: FirebaseUser): User?
Link copied to clipboard
fun deleteAccount(): Task<Void>?
Link copied to clipboard
private suspend fun firebaseAuthWithGoogle(idToken: String): FirebaseUser?

Sign in to Firebase using Google ID Token https://firebase.google.com/docs/reference/kotlin/com/google/firebase/auth/GoogleAuthProvider

Link copied to clipboard
Link copied to clipboard
suspend fun getTopUsers(): Result<List<User>>
Link copied to clipboard
private suspend fun getUsers(ids: List<String>): List<User>
Link copied to clipboard
fun init(ctx: Context)
Link copied to clipboard
private inline fun <T> runIfLoggedIn(block: () -> T): T?
Link copied to clipboard
private inline fun <T> runIfLoggedInWithResult(block: () -> Result<T>): Result<T>

Wraps a block that produces a result and returns it, or returns other Result (like failure) coming from other conditions checks from this function

Link copied to clipboard
suspend fun signInWithGoogle(ctx: Context): User?
Link copied to clipboard
suspend fun signOut(): Result<Unit?>?

Clear the current user credential state from all credential providers

Link copied to clipboard
suspend fun updateUserAchievements(achievements: List<UserAchievement>, points: Float): Result<Unit>