Created
July 15, 2020 18:15
-
-
Save yashovardhan99/6bd2ee51c8c83b1cd058cb268615305e to your computer and use it in GitHub Desktop.
Kotlin MVVM Firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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