Reputation: 1396
Update:I found this isn't main reason of increase usage.
I'm already using notification key to send notification.And I knew is that can't subscribe notification key to a topic.But we need a user can login same account on multiple devices. So I decide save notification key on realtime database.
How my application work is when a user send a message to chatroom then cloud function triggered and read data once(group_chatroom_notification_keys/chatroom_id_1) to get all user_notification_key_n and send notification to each user. Problem is send every message need read chatroom all notification key again.This way increase so much realtime database GB downloaded.I paid 35% of earn to google every month now.
I also a bit confuse this doc say:
"For fast, secure delivery to single devices or small groups of devices, target messages to registration tokens, not topics."
what does it mean secure delivery? If I using chatroom_id as topic and subscribe all chatroom users token to topic for reduce the cost. Then chatroom notification data will steal by other device? because all chatroom should be private and I don't know how to reduce the cost correctly.
Someone have better way to do this? The cost for this is necessary?
Upvotes: 0
Views: 262
Reputation: 296
You shouldn't be reading keys again and again. I have build private chat rooms app too. The way I used it is:
When user open chat room I load all users key only once. Now no matter how many times I Send message I pass all loaded keys to Cloud functions and CF fire notifications. I hope it helps and save you some data usage.
Upvotes: 1