服务器中的Firebase令牌管理 [英] Firebase token management in servers

查看:70
本文介绍了服务器中的Firebase令牌管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是刚接触Firebase和android通知.我希望能够根据一些规则将通知发送给单个用户.到目前为止,我一直在阅读的内容是可以通过以下方式生成令牌:

I still new with firebase and android notifications. I want to be able to send notifications to a single user based on some rules. What I've been reading so far is that a token can be generated with:

FirebaseInstanceId.getInstance().getToken()

然后,令牌将在过期时的某个时候需要刷新.

Then, the token will need to be refreshed at some point when it expires.

如果可能的话,如何设置这些令牌的有效期?如果大约有一千个用户在同一时间刷新其令牌,那么我将需要对这些令牌进行一千次写入我的应用服务器的操作.是否有解决此问题的已知缩放解决方案(例如,保留相同的令牌但仅刷新其到期时间)?

How to I set expiry for these tokens, if at all possible? If there are a thousand users having their tokens refreshed around the same time then I will need to do a thousand writes for these tokens to my app servers. Is there a known scaling solution for this problem (eg. keep the same token but refresh its expiry only)?

推荐答案

在以下情况下,注册令牌可能会更改:

The registration token may change when:

  • 该应用程序删除实例ID
  • 该应用已在新设备上还原
  • 用户卸载/重新安装应用程序
  • 用户清除应用数据.

除了删除令牌(上面的第一个选项)之外,您无法控制何时刷新令牌.但是与Firebase身份验证令牌不同,Firebase Cloud Messaging的实例ID令牌不会按固定的时间表刷新.实例ID令牌刷新相对很少见,只需要特殊考虑就可以在最大的用例中进行扩展.

Beyond deleting the token (the first option above), you have no control over when a token is refreshed. But unlike Firebase Authentication tokens, the Instance ID Tokens of Firebase Cloud Messaging don't refresh on a fixed schedule. Instance ID Token refreshes are relatively rare and should only need special considering for scaling out in the largest use-cases.

这篇关于服务器中的Firebase令牌管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆