【问题标题】:Error Firestore. <asynchronous suspension>错误 Firestore。 <异步挂起>
【发布时间】:2021-01-26 15:42:23
【问题描述】:

昨天(12.10.2020)我的代码正在运行。但是今天他写错了。

文档名称正确。 谢谢。

Future loadDataQuest() async {
  while (i < 10) {
    var fen = await FirebaseFirestore.instance
        .collection('questions')
        .doc(notSee[i])
        .get()
        .asStream()
        .map((DocumentSnapshot doc) => Quest.fromJson(doc.id, doc.data()))
        .toList();
    quest.add(fen[0]);
    i++;
  }
  print(quest);
}

错误:

W/Firestore(10953): (21.4.3) [Firestore]: Listen for Query(target=Query(questions/5WlbNnrXMCM8CNrnhBxl order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
E/flutter (10953): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.

E/flutter (10953): #8      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart)
E/flutter (10953): <asynchronous suspension>

【问题讨论】:

  • 权限被拒绝错误,请在 Firebase 控制台中检查您的 Firestore 规则

标签: firebase flutter dart google-cloud-firestore async-await


【解决方案1】:

Sai Gopi Me的真实回答

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
  allow read, write: if false;
  }
 }
}

改成这个

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
 match /{document=**} {
  allow read, write: if request.auth != null;
  }
 }
}

【讨论】:

  • 小心这些规则,因为它们允许任何经过身份验证的用户完全读写整个数据库,这可能不是您想要的生产应用程序。跨度>
猜你喜欢
  • 2021-09-18
  • 2021-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-28
  • 1970-01-01
相关资源
最近更新 更多