我要开发一个使用设备组功能的应用程序。据我了解,我需要首先将我在 Android 客户端上使用 onTokenRefresh
方法获得的当前注册 token 发送到服务器,然后将此注册 token 添加到适当的设备组(如果不存在则创建它)通过 HTTP 请求。然而,我看到了泄漏注册 token 的可能性,因为 Android 应用程序用户可能会多次删除应用程序的数据。如何预防?当超过 20 个成员的限制时会发生什么?是否可以检查某个组是否已经存在?
最佳答案
I see, however, a potential for leaking registration tokens, as Android app user may for example wipe app's data multiple times. How to prevent it?
如果阻止是指在应用程序管理器中为您的应用程序禁用清除数据,您应该引用此post . accepted answer声明这是不可能的。
然而,Jakar's answer提供了一种变通方法,其中 Clear Data 将显示为 Manage Spaces。还没有尝试过,所以我不能肯定地说。不过,赞成票不言而喻。
但是,如果应用程序的数据被用户删除/清除,您应该引用 FirebaseInstanceId 中的说明文档:
Instance ID is stable except when:
App deletes Instance ID
App is restored on a new device
User uninstalls/reinstall the app
User clears app data
In the above cases a new
Instance ID
is generated and the application needs to recreate the authorization tokens previously generated implementingonTokenRefresh()
.
What happens when a limit of 20 members is exceeded?
不确定这里的问题是什么......但是如果你要将设备添加到设备组超过最大值......
无法在 FCM: Device Group Messaging 中找到明确说明的内容文档,但如果您引用添加到组部分,它指出:
A successful operation returns a
notification_key
.
因此,我认为如果您尝试将另一台设备添加到已经已满的设备组,操作将失败。
我建议使用 Topics相反,如果你认为你要超过 20 个。但我真的不知道你的用例是什么,所以..你的电话。
And is it possible to check whether some group already exists or not?
为此,您应该使用notification_key
和notification_key_name
。根据 docs :
The
notification_key_name
is a name or identifier (e.g., it can be a username) that is unique to a given group. Thenotification_key_name
andnotification_key
are unique to a group of registration tokens. It is important thatnotification_key_name
is unique per client app if you have multiple client apps for the same sender ID. This ensures that messages only go to the intended target app.
并强调声明:
Basic management of device groups — creating and removing groups, and adding or removing devices — is usually performed via the app server.
key 和名称应该在您的服务器上,以便您可以检查它是否已经存在。
关于android - Firebase 云消息传递设备组泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38079378/