Swift Firebase必须是非空字符串,不能包含“。” '#''$''['或']' [英] Swift Firebase Must be a non-empty string and not contain '.' '#' '$' '[' or ']'
问题描述
我正在使用该行
如果snapshot.hasChild(email){
电子邮件test1@test.com
当我输入那个时候,我到达。之前,应用程序崩溃,并给出了一个错误,说这个
必须是非空字符串,不能包含'。'''''''''''''''''''
我看到很多关于检查用户名的帖子,但我的应用程序没有用户名,只是电子邮件。我能够使用电子邮件与
hasChild(...){...
$ c $ Firebase密钥不能包含
(点)字符。如果你想在一个密钥中存储一个电子邮件地址,你必须对它进行编码。通常的做法是用,
(逗号)替换。
,这是不方便的电子邮件地址。所以 test1@test.com
会被编码为 test1 @ test,com
。
我不认为您实际上是将电子邮件地址存储为密钥,但是我会跟进您之前的问题。
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 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 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屋!