java - GCM canonical id -


when having multiple regids 1 device gcm returns canonical id error:

{"multicast_id":xxxx,"success":2,"failure":0,"canonical_ids":1,"results":[{"message_id":"xxxxx"},{"registration_id":"newest reg id here","message_id":"xxxxxx"}]} 

so shows newest regid should used gcm why isn't showing regid should delete (the old one)? how know old regid , 1 should delete database?

eran's answer correct, though found still bit foggy me. however, him found solution.

say 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 can see 2 of 7 messages duplicate.

this way send messages server:

$tokenresult = mysql_query("select reg_ids table_with_regids"); // $i = 0; while($row = mysql_fetch_array($tokenresult)) {       $registrationids[$i] = $row['reg_ids'];      $i++; } 

from eran's answer:

since response google each request send, should know registration ids sent google in request triggered response. old registration id have delete second registration id in request.

this means index 2 , 5 of array $registrationids[] should replaced my_reg_id_1 , my_reg_id_2.

finally check double values , remove exact duplicates. result should array 5 regids (or directly delete index array instead of replacing my_reg_id_#).


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -