How to send GCM messages to multiple devices at a time

后端 未结 1 1507
故里飘歌
故里飘歌 2020-12-01 21:05

I want to send same message to multiple devices in android using GCM. Currently i am able to send push notification to my device as i am explicitly specifying my registratio

相关标签:
1条回答
  • 2020-12-01 21:33

    What you should do is send multiple registrations Ids (up to 1000 at once) when you send your message to GCM, and you will need to use JSON as your request format.

    You can read more about that here: https://developers.google.com/cloud-messaging/server-ref#downstream

    You will need to add your list of Id's to the registration_ids field:

    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). Required.

    Here is an example request from their docs:

    Here is a message with a payload and 6 recipients:

    { "data": {
       "score": "5x1",
       "time": "15:10"
      },
      "registration_ids": ["4", "8", "15", "16", "23", "42"]
    } 
    
    0 讨论(0)
提交回复
热议问题