【发布时间】:2021-10-26 02:46:54
【问题描述】:
我正在用颤振编写聊天应用程序,我不知道如何在 firebase 上设置规则,这样只有群聊中的 2 个用户可以读写。这就是我在 firebase 上存储消息的方式。
String date = DateTime.now().millisecondsSinceEpoch.toString();
groupId = userId-anotherId
var ref = FirebaseFirestore.instance
.collection('messages')
.doc(groupId)
.collection(groupId)
.doc(date);
FirebaseFirestore.instance.runTransaction((transaction) async {
transaction.set(ref, {
"senderId": userId,
"receiverId": anotherId,
"timestamp": date,
'content': msg,
"type": 'text',
});
});
感谢您的帮助。
【问题讨论】:
标签: android firebase flutter google-cloud-firestore firebase-security