Reputation:
This is a follow up to my previous question. I am trying to see if an email has already been used.
I am using the line
if snapshot.hasChild(email) {
I have in my database an email [email protected] When I type that in..the moment I get to the '.' before com the app crashes and gives an error that says this
Must be a non-empty string and not contain '.' '#' '$' '[' or ']'
I see a lot of posts about checking for usernames, but my app doesn't have usernames, just email. Am I able to use email with
hasChild(...) {...
Upvotes: 1
Views: 2715
Reputation: 599031
Firebase keys cannot contain a .
(dot) character. If you want to store an email address in a key, you'll have to encode it. The common way to do that is to replace the .
with a ,
(comma), which conveniently is not allowed in email addresses. So [email protected]
would be encoded as test1@test,com
.
I don't think you're actually storing the email address as a key, but I'll follow up for that on your previous question.
Upvotes: 5