如何在Firebase中将电子邮件地址添加为子地址? [英] How to add email address as child in Firebase?

查看:125
本文介绍了如何在Firebase中将电子邮件地址添加为子地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个Android App,我想要一个Firebase数据库,例如

I am working on an Android App where I want a Firebase database like

基本上,我想在应用上创建用户之前先验证电子邮件.每当用户在我的应用程序中注册时,首先将检查用户数据库参考中的电子邮件地址是否可用.如果有的话,那么只有他被允许注册. 但是我发现Firebase不允许在儿童时期发送电子邮件.那我该怎么办呢?在Firebase数据库中实现此目的的任何其他建议.

Basically, I want to verify email before creating a user on the app. Whenever a user registers in my app, First it will be checked whether the email address is available in the users database reference. if available, then only he is allowed to register. But I found that Firebase doesn't allow an email as a child. So How can I do it? Any other suggestion for achieving this in Firebase Database.

推荐答案

因为Firebase不允许密钥中的符号作为.,所以建议您对电子邮件地址进行如下编码:

Because Firebase does not allow symbols as . in the key, I suggest you encode the email address like this:

name@email.com-> name @ email,com

name@email.com -> name@email,com

如您所见,

我使用的是,而不是..为此,可以使用以下方法:

As you probably see, instead of . I have used ,. To achieve this, you can use the following methods:

static String encodeUserEmail(String userEmail) {
    return userEmail.replace(".", ",");
}

static String decodeUserEmail(String userEmail) {
    return userEmail.replace(",", ".");
}

这篇关于如何在Firebase中将电子邮件地址添加为子地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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