在使用电话身份验证时,如何设置firebase用户的外交名称
我正在创建一个正在实施Firebase电话身份验证的Android按摩应用程序。当我创建PhoneAuthOptions时,我没有看到任何设置用户显示名称的方法,在验证完成后,我需要用户名称将其保存在数据库中。在设置用户的语音数时,我可以设置用户的显示名称吗?
val options=PhoneAuthOptions.newBuilder(mAuth)
.setPhoneNumber(number)
.setTimeout(60L,TimeUnit.SECONDS)
.setActivity(this)
.setCallbacks(callbacks)
.build()
PhoneAuthProvider.verifyPhoneNumber(options)
Log.d("MSG","Auth started")
}
这是OTP活动代码,当我获得CurrentUser的PhoneNumber时,我也想获取用户的DisplayName。我想在UID代替商店displayName。
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this){ task->
if(task.isSuccessful){
val pref : SharedPreferences = getSharedPreferences("login", MODE_PRIVATE)
val editor : SharedPreferences.Editor = pref.edit()
editor.putBoolean("LogedIn", true).apply()
mDB = FirebaseDatabase.getInstance()
mDBRef = mDB.getReference()
val phoneNumber = mAuth.currentUser?.phoneNumber!!
val uid = mAuth.currentUser?.uid!!
mDBRef.child("Users").child(phoneNumber).setValue(uid)
startActivity(Intent(this, MainActivity::class.java))
finish()
}
else {
Toast.makeText(this, "Invalid OTP", Toast.LENGTH_SHORT).show()
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
登录用户后,您可以通过调用
Update Profile
在其用户
对象上设置其显示名称,如。从那里:Once the user is signed in, you can set their display name by calling
updateProfile
on theirUser
object as shown in the documentation on updating the user's profile. From there: