相关疑难解决方法(0)

使用公共数据库的Firebase聊天应用setValue失败错误?

我有一个使用Firebase的聊天应用程序,它继续使用

x处的setValue失败:DatabaseError:权限被拒绝

每次输入消息时都会出错.

我已将数据库设置为公开:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{allPaths=**} {
      allow read, write: if request.auth.uid != null;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的聊天参考内容吗?

private void displayChat() {

    ListView listOfMessage = findViewById(R.id.list_of_message);

    Query query = FirebaseDatabase.getInstance().getReference();
    FirebaseListOptions<Chat> options = new FirebaseListOptions.Builder<Chat>()
            .setLayout(R.layout.list_item)
            .setQuery(query, Chat.class)
            .build();

    adapter = new FirebaseListAdapter<Chat>(options) {
        @Override
        protected void populateView(View v, Chat model, int position) {
            //Get reference to the views of list_item.xml
            TextView messageText, messageUser, messageTime;
            messageText = v.findViewById(R.id.message_text);
            messageUser = v.findViewById(R.id.message_user);
            messageTime = v.findViewById(R.id.message_time); …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-realtime-database firebase-security-rules

0
推荐指数
1
解决办法
1141
查看次数