Eran's answer is correct, though I found it still a bit foggy for me. However, thanks to him I found a solution.
Say this is your response:
{
"multicast_id":xxxxx,
"success":7,
"failure":0,
"canonical_ids":2,
"results":[
{
"message_id":"0:xxx%xxxxx"
},
{
"message_id":"0:xxx%xxxxx"
},
{
"registration_id":"MY_REG_ID_1",
"message_id":"0:xxx%xxxxx"
},
{
"message_id":"0:xxx%xxxxx"
},
{
"message_id":"0:xxx%xxxxx"
},
{
"registration_id":"MY_REG_ID_2",
"message_id":"0:xxx%xxxxx"
},
{
"message_id":"0:xxx%xxxxx"
}
]
}
As you can see 2 of the 7 messages are a duplicate.
This is the way I send messages to the server:
$tokenResult = mysql_query("SELECT reg_ids FROM table_with_regids"); //
$i = 0;
while($row = mysql_fetch_array($tokenResult)) {
$registrationIDs[$i] = $row['reg_ids'];
$i++;
}
from Eran's answer:
Since you get a response from Google for each request you send, you
should know which Registration IDs were sent to Google in the request
that triggered this response. The old Registration ID that you have to
delete is the second Registration ID in that request.
This means that index 2 and 5 of the array $registrationIDs[] should be replaced with MY_REG_ID_1 and MY_REG_ID_2.
Finally check for double values and remove the exact duplicates. The result should be an array with 5 regids (or directly delete that index from your array instead of replacing with MY_REG_ID_#).