【问题标题】:Realtime database storage issues in firebase of android appandroid应用程序的firebase中的实时数据库存储问题
【发布时间】:2018-09-17 07:55:30
【问题描述】:

身份验证,新用户验证工作正常,但在实时数据库中,没有任何用户信息被存储。

/在firebase方法中/

public void addNewUser(String email, String username, String description, String website, String profile_photo){
    User user = new User( userID,  1,  email,  StringManipulation.condenseUsername(username) );

    myRef.child(mContext.getString(R.string.dbname_users))
            .child(userID)
            .setValue(user);


    UserAccountSettings settings = new UserAccountSettings(
            description,
            username,
            0,
            0,
            0,
            profile_photo,
            username,
            website
    );

    myRef.child(mContext.getString(R.string.dbname_user_account_settings))
            .child(userID)
            .setValue(settings);

}

【问题讨论】:

标签: android firebase firebase-realtime-database


【解决方案1】:

正如弗兰克所说,您必须从数据库中为您的规则启用读取、写入权限

然后在里面就可以更改以下参数了

允许用户从您的数据库中读取所有数据,但如果他们未通过身份验证则不允许写入

"rules": {
    ".read": true,
    ".write": "auth!=null"
 }

允许用户在您的数据库中读取和写入文档而无需进行身份验证(不安全)

 "rules": {
        ".read": true,
        ".write": true
     }

或者只是使用最佳选项,即仅当用户使用任何Firebase Auth 选项登录时才允许读写

"rules": {
            ".read": "auth!=null",
            ".write": "auth!=null"
         }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-26
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2018-01-12
    • 2020-03-21
    • 2019-09-06
    • 2018-12-04
    相关资源
    最近更新 更多