Swift 3 "updateChildValues" method fails with: Invalid key in object. Keys must be non-empty and cannot contain '.' '#' '$' '[' or ']''

Viewed 1102

I'm trying to update Firebase Database with email as value. But Swift 3 "updateChildValues" method fails with an error: Invalid key in object. Keys must be non-empty and cannot contain '.' '#' '$' '[' or ']'' The code is:

    let key = emailQueueRef.childByAutoId()
    if user.email != nil {
        inviteUpdate["\(key)"] = user.email!
    }
    emailQueueRef.updateChildValues(inviteUpdate)

Possibly, it fail because of dots in email. In other hand, encoding it into Base64 didn't fix it. In the same time using "setValue" method works:

    emailQueueRef.childByAutoId().setValue(user.email!)

But this approach is not quite good for me as I make it with several paths simultaneously. I didn't find anything about that case in Firebase guides and docs Is it a Firebase bug, or I misunderstood something?

2 Answers
Related