Validate username and email crashed and cannot insert to firebase database

后端 未结 2 867
感动是毒
感动是毒 2021-01-25 19:59

The apps cannot insert any data to the database while this line of code makes error to the apps.

ref.child(uid).orderByChild(\"username\").equalTo(validateName)         


        
2条回答
  •  失恋的感觉
    2021-01-25 20:23

    As your error said, Firebase Database paths must not contain '.', '#', '$', '[', or ']'. This means that Firebase does not allow you use in the key symbols those symbols. Because of that, you need to econde the email address like this:

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

    To achieve this, i recomand you using the following methods:

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

提交回复
热议问题