gpt4 book ai didi

firebase - 管理 FCM 设备组

转载 作者:行者123 更新时间:2023-12-04 00:59:55 34 4
gpt4 key购买 nike

我试图弄清楚如何使用 REST API 从应用服务器管理 FCM 设备组。

AFAIK 这些是更新的文档:https://firebase.google.com/docs/cloud-messaging/android/device-group#managing_device_groups

这是我已经可以做的:

  • 使用一些设备 token 创建一个新设备组
  • 将设备 token 添加到现有设备组

  • 这就是我无法弄清楚该怎么做,因为文档中没有提到它:
  • 查询设备组是否已经存在,根据其notification_key_name .

    解决方法 1:如果我尝试使用 notification_key_name 创建一个组
    已经存在然后我收到一个错误告诉我,但这似乎
    就像一种非常hacky的方式来找出答案。

    解决方法 2:我自己将这些信息存储在其他地方。
  • 找出哪些设备 token ( registration_id ) 属于设备组。

    解决方法:和以前一样,自己将这些信息存储在其他地方。
  • 从设备组中删除设备 token ( registration_id )。

    解决方法:无。
  • 删除设备组。

    解决方法:无。

  • 谢谢!

    最佳答案

    • Query whether a device group already exists, based on its notification_key_name.


    您的第二个解决方法是要走的路。您应该将它存储在您的应用程序服务器中,与您还存储注册 token 的位置相同。

    • Finding out which device tokens (registration_id) belong to a device group.


    与上面的解决方法相同。您必须在您的应用服务器上管理这些详细信息。管理这些细节是开发人员的责任。如果注册设备被删除,则匹配操作,您也必须将其从应用服务器中删除。

    • Remove device tokens (registration_id) from a device group.


    我不确定你在这里需要什么。 documentation有关于从设备组中删除注册 token 的详细信息:

    Adding and removing devices from a device group

    To add or remove devices from an existing group, send a POST request with the operation parameter set to add or remove, and provide the registration tokens for addition or removal.

    Note: If you remove all existing registration tokens from a device group, FCM deletes the device group.

    HTTP POST request

    For example, to add a device with the registration ID 51 to appUser-Chris, you would send this request:

    {
    "operation": "add",
    "notification_key_name": "appUser-Chris",
    "notification_key": "APA91bGHXQBB...9QgnYOEURwm0I3lmyqzk2TXQ",
    "registration_ids": ["51"]
    }

    Response format

    A successful request to either add or remove a device returns a notification_key like the following:

    {
    "notification_key": "APA91bGHXQBB...9QgnYOEURwm0I3lmyqzk2TXQ"
    }

    Note: notification_key_name is not required for adding/removing registration tokens, but including it protects you against accidentally using the incorrect notification_key.



    • Remove a device group.


    从上面文档中的注释:

    Note: If you remove all existing registration tokens from a device group, FCM deletes the device group.

    关于firebase - 管理 FCM 设备组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42515390/

    34 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com