Swift Firebase 必须是非空字符串且不包含“."'#' '$' '[' 或 ']' [英] Swift Firebase Must be a non-empty string and not contain '.' '#' '$' '[' or ']'

查看:30
本文介绍了Swift Firebase 必须是非空字符串且不包含“."'#' '$' '[' 或 ']'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对我上一个问题的跟进.我正在尝试查看电子邮件是否已被使用.

This is a follow up to my previous question. I am trying to see if an email has already been used.

我正在使用线

if snapshot.hasChild(email) {

我的数据库中有一封电子邮件 test1@test.com当我输入时..在我到达."的那一刻在 com 之前应用程序崩溃并给出一个错误提示

I have in my database an email test1@test.com 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(...) {...

推荐答案

Firebase 键不能包含 .(点)字符.如果要将电子邮件地址存储在密钥中,则必须对其进行编码.这样做的常用方法是将 . 替换为 ,(逗号),这在电子邮件地址中是不允许的.所以 test1@test.com 将被编码为 test1@test,com.

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 test1@test.com 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.

这篇关于Swift Firebase 必须是非空字符串且不包含“."'#' '$' '[' 或 ']'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆