Flutter FCM Topic 命名为文档
Flutter FCM Topic named like a document
我是 firebase 云消息传递的新手,我正在寻找向客户发送通知的最佳方式。
我希望人们能够像这样订阅子集合中的新条目:
books/{bookID}/comments/{commentId}/reply/{replyId}}
如果我使用那种语法会很糟糕吗?
所以我可以在创建新回复时推送关于该主题的通知
void fcmSubscribe(String bookId,String commentId) {
firebaseMessaging.subscribeToTopic('book-${bookiD}_comment-${commentId}');
}
或者我需要使用个人设备通知并创建这样的条目
books/{bookID}/comments/{commentId}/notifications/{tokenId}}
我想避免使用 firestore 读写。
您可以使用任何 that you want. Use whatever you like - it's your choice. There is nothing particularly "bad" about your choice of name, as long as it works for you. Things can only go badly for you if you exceed one of the documented limits 主题消息:
Topic messaging supports unlimited subscriptions for each topic. However,
FCM enforces limits in these areas:
- One app instance can be subscribed to no more than 2000 topics.
- If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
- The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM
servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded")
response. Retry with exponential backoff.
如果您认为 FCM 以任何方式与 Firestore 相关联,那么事实并非如此。您没有义务在您的 Firesore 文档和您的 FCM 主题之间进行任何匹配。
我是 firebase 云消息传递的新手,我正在寻找向客户发送通知的最佳方式。
我希望人们能够像这样订阅子集合中的新条目:
books/{bookID}/comments/{commentId}/reply/{replyId}}
如果我使用那种语法会很糟糕吗? 所以我可以在创建新回复时推送关于该主题的通知
void fcmSubscribe(String bookId,String commentId) {
firebaseMessaging.subscribeToTopic('book-${bookiD}_comment-${commentId}');
}
或者我需要使用个人设备通知并创建这样的条目
books/{bookID}/comments/{commentId}/notifications/{tokenId}}
我想避免使用 firestore 读写。
您可以使用任何
Topic messaging supports unlimited subscriptions for each topic. However,
FCM enforces limits in these areas:
- One app instance can be subscribed to no more than 2000 topics.
- If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
- The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.
如果您认为 FCM 以任何方式与 Firestore 相关联,那么事实并非如此。您没有义务在您的 Firesore 文档和您的 FCM 主题之间进行任何匹配。