Firebase路径无效:Firebase路径不得包含“。”,“#”,“$”,“[”或“]”

时间:2018-04-18 16:43:17

标签: firebase app-inventor

即时通过firebase在appinventor上创建应用程序,当我向firebase引入电子邮件时,我遇到了错误,如何解决?

Firebase路径无效:Firebase路径不得包含“。”,“#”,“$”,“[”或“]”

6 个答案:

答案 0 :(得分:1)

Using email address as a key in Firebase Realtime Database is not a very good idea. Email addresses are problematic because they are not case sensitive, users may change them over time, and as you've see, they contain invalid characters.

Instead, you should use some other identifier, such as an automated push id, or some other unique id. You can store the email address as a child value within the space you create for each user, and you can query users to look for a specific email address later, if you like.

If you really must use an email address as a child key, you'll need to encode the string some way in order to remove the invalid characters, and always remember to encode email address strings the same way when searching for the user by that email.

答案 1 :(得分:1)

如果值包含. # $ [ ]

,则存储到firebase的示例

image

答案 2 :(得分:0)

很简单,在使用电子邮件地址之前,请替换所有的“。”。带有“ 1”。

因此,此电子邮件“ example@email.com”将类似于“ example @ email1com”。

也可以这样做以替换任何其他非法字符。

答案 3 :(得分:0)

这似乎可行

Utils.EncodeString(user.email)

欢呼

答案 4 :(得分:0)

您会收到此异常,因为电子邮件包含无效字符,例如“。”。和'@'对Firebase数据库无效。而是使用用户ID。 只需使用FirebaseAuth.getInstance().getCurrentUser().getUid()。 希望问题应该解决。

答案 5 :(得分:0)

我在尝试使用 orderBy 时收到此错误,因为我从 UI 中复制粘贴如下内容:

.collection("my_collection").orderBy("", "asc")

忘记填写里面的"" ...