小编Bas*_*ngs的帖子

在Firebase身份验证中使用signInWithEmailAndPassword时如何使用协程?

我想在 firebase 中使用协程来实现登录功能

 private suspend fun signin() {

    var email = binding.emailArea.text.toString()
    var password = binding.passwordArea.text.toString()
    return withContext(Dispatchers.IO) {
        auth.signInWithEmailAndPassword(email,password).await()
    }
}
Run Code Online (Sandbox Code Playgroud)

但我不知道签名函数真正返回什么。

CoroutineScope(Dispatchers.IO).launch {
    val result = async { signin() }
    //how to utilize result?
}
Run Code Online (Sandbox Code Playgroud)

我知道等待返回被推迟。但我不知道如何使用这个功能。

android kotlin firebase firebase-authentication kotlin-coroutines

1
推荐指数
1
解决办法
259
查看次数