gpt4 book ai didi

Android GCM - 向 registration_ids 数组中的每个用户发送不同的有效负载

转载 作者:太空狗 更新时间:2023-10-29 14:20:19 25 4
gpt4 key购买 nike

在多播 GCM 触发器中,我想向每个用户发送不同的负载。我的GCM json对应数组如下:

$fields = array(
'collapse_key' => 'demo',
'registration_ids' => $registration_ids,
'data' => array('myjson' => 'abc'),
);

考虑 registeration_ids 数组如下:

$registration_ids => array('id1','id2','id3');

有了上面提到的 GCM json 对应的数组,所有用户都得到相同的 'myjson' 值。有什么方法可以设计 json 对应的数组,使得“id1”获取“abc”作为“myjson”的值,“id2”获取“def”作为“myjson”的值......等等?

最佳答案

这是不可能的。多播消息只允许您向多个注册 ID 发送相同的消息。

  • A 3rd-party application server can either send messages to a single device or to multiple devices. A message sent to multiple devices simultaneously is called a multicast message.
  • To send a single message to multiple devices owned by a single user, you can use a notification_key, as described in User Notifications.
  • You have 2 choices in how you construct requests and responses: plain text or JSON.
  • However, to send multicast messages, you must use JSON. Plain text will not work.

registration_ids A string array with the list of devices (registration IDs) receiving the message. It must contain at least 1 and at most 1000 registration IDs. To send a multicast message, you must use JSON. For sending a single message to a single device, you could use a JSON object with just 1 registration id, or plain text (see below). A request must include a recipient—this can be either a registration ID, an array of registration IDs, or a notification_key.

请注意,在多播消息中,您仍在发送单个消息。 JSON 请求中唯一可以具有多个值的参数是 registration_ids

要向不同的设备发送不同的消息,您必须为每台设备发送一个请求(带有单一注册 ID 的 JSON 或纯文本)。

关于Android GCM - 向 registration_ids 数组中的每个用户发送不同的有效负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17692353/

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