android - Firebase 云消息传递设备组泄漏

标签 android firebase firebase-cloud-messaging

我要开发一个使用设备组功能的应用程序。据我了解,我需要首先将我在 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 implementing onTokenRefresh().


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_keynotification_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. The notification_key_name and notification_key are unique to a group of registration tokens. It is important that notification_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/

相关文章:

firebase - 已收到 Xamarin Forms 推送通知但未显示/出现

java - 原因:failed to find target with hash string 'android-14 (Don' t have API 14 in SDK manager)

android - 如何在 Android 中调用电话并在通话结束后返回到我的 Activity ?

javascript - 在状态更改之前调用我的函数

android - 如何在 couchbase 同步网关中使用 firebase 身份验证

javascript - 如何将客户端 Firebase Cloud 消息 token 获取到 Google Cloud 功能?

android - 为什么视频 View 大小会根据视频大小自动更改?

android - 有没有办法在通过谷歌云平台运行的 Windows Server 2019 上启用 VT-X

ios - 从 Firebase 检索键的特定值列表

android - 可以在一个 Android 应用程序中使用两个不同的 Firebase 项目,特别是 crashlytics、消息传递和性能扩展