swift - Firebase swift - 无法将类型 'FIRUserInfoImpl' 的值转换为 'NSDictionary'

标签 swift firebase firebase-realtime-database firebase-authentication

我有一个 facebook 和 twitter 登录按钮。我关注user guide .我想存储用户信息,但收到此错误 Could not cast value of type 'FIRUserInfoImpl' to 'NSDictionary'

我不确定为什么我不能存储相关数据。是因为提供者数据与对象类型不匹配吗?

func createFirebaseUser(){

        //MARK: Assign what to get from current User data.
        let key = ref.child("users").childByAutoId().key
        if let user = FIRAuth.auth()?.currentUser{
        for profile in user.providerData {
        let userID = profile.uid as! String!
        let username = profile.displayName as! String!
        let email = profile.email as! String!
        let profilePicUrl = profile.photoURL as! NSURL!


        ref.child("users").updateChildValues(profile as? NSDictionary as! [NSObject : AnyObject])

        }
        }

最佳答案

您应该创建一个字典来使用 updateChildValues 发送数据。

关于swift - Firebase swift - 无法将类型 'FIRUserInfoImpl' 的值转换为 'NSDictionary',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37831821/

相关文章:

swift - 遇到线程 1 : EXC_BAD_ACCESS (code=2) when using custom segue

ios - 在 iOS 中说的每一句话都会改变图像?

Firebase 实时数据库规则(所有人都可以读取但只能编辑所有者)

ios - 给定用户 UID,我可以访问他的个人资料信息吗?

node.js - 无法使用 GitHub 个人访问 token 对 Firebase 进行身份验证(以前有效)

javascript - PERMISSION_DENIED(为错误的数据库产品设置的规则)

swift - 我在 void 函数错误中有一个意外的非 void 返回值?

ios - 有没有办法使用用户默认值来更改我的所有 IOS 应用程序页面的背景颜色?

ios - UIAlertController 内的多行可编辑文本 UITextview?

firebase - 从 Google Cloud Storage 获取更短的文件 URL(使用 Firebase Cloud Functions)