Skip to content

Instantly share code, notes, and snippets.

@yashovardhan99
Created July 15, 2020 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yashovardhan99/6bd2ee51c8c83b1cd058cb268615305e to your computer and use it in GitHub Desktop.
Save yashovardhan99/6bd2ee51c8c83b1cd058cb268615305e to your computer and use it in GitHub Desktop.
Kotlin MVVM Firebase
object FirebaseProfileService {
private const val TAG = "FirebaseProfileService"
suspend fun getProfileData(userId: String): User? {
val db = FirebaseFirestore.getInstance()
return try {
db.collection("users")
.document(userId).get().await().toUser()
} catch (e: Exception) {
Log.e(TAG, "Error getting user details", e)
FirebaseCrashlytics.getInstance().log("Error getting user details")
FirebaseCrashlytics.getInstance().setCustomKey("user id", xpertSlug)
FirebaseCrashlytics.getInstance().recordException(e)
null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment