I am using Google Cloud Messaging for my Android application and I am trying to understand when the registration id expires. From this post I was able to understand that Goo
To obtain the latest GCM ID Here is my work around.
$result = curl_exec($ch);
$result = json_decode($result, true);
$GCMIDChanged = $result['canonical_ids'];
if($GCMIDChanged)
{
$NewGCMId = $result['results'][0]['registration_id'];
//Update your DB with $NewGCMId
}
In the above code, I am checking whether the canonical_ids exists in the result.
If the canonical_ids exists then i am getting the new registration_id
So, Now the system will update automatically the New Gcm Id whenever it is changed.
Update :
The below code can be used if the GCM Id is changed multiple times
$GCMIDChanged = $result['canonical_ids'];
if($GCMIDChanged)
{
$NewGCMIdList = end($result['results']);
$NewGCMId = $NewGCMIdList['registration_id'];
}