ios - iOS/Swift/Firebase 身份验证:访问“isNewUser”需要帮助
问题描述
在我的 iOS/Swift/Firebase 应用程序中,我试图在用户通过电子邮件/密码成功登录后访问“isNewUser”参数,以便我可以弹出一个窗口强制他们从最初分配的临时密码中重置密码用户创建。
任何见解将不胜感激。谢谢。
解决方案
Bool可.isNewUser
从 FirebaseAuth AdditionalUserInfo 类获得。
这是链接。为了使用此代码,请查看我在下面编写的演示登录功能。
Auth.auth().signIn(with: credential) { (result, error) in
if let error = error {
print("Error: \(error)");
return;
}
// Fetch the user's info
guard let uid = result?.user.uid else {return}
// Safely unwrap the boolean value rather than forcing it with "!" which could crash your app if a nil value is found
guard let newUserStatus = result?.additionalUserInfo?.isNewUser else {return}
// Test the value
print("\nIs new user? \(newUserStatus)\n")
if newUserStatus == true {
// Provide your alert prompt
}
else{
// Transition view to continue into the app
}
}
推荐阅读
- php - 从对象获取php数组
- android - 保持连接 BLE 设备,即使应用程序在没有通知的情况下被杀死,如 Gear 应用程序的 Android Oreo
- android-fragments - 如何在片段内打开BottomSheetDialog
- r - 将表达式字符串转换为可引用的表达式
- r - 在 R 中使用命名对象创建列表并从此列表中检索部分对象
- java - apache olingo 有客户端类生成器吗?
- javascript - 在新选项卡中打开链接并在当前选项卡中触发回发
- unit-testing - 使用设置和验证时在 Moq 中定义 Mocks 的最佳实践
- c++ - 指向对象内存位置的指针已在程序中删除,但仍提供正确答案而不是垃圾值
- excel - VBA在搜索框IE中插入数据