android - Google Cloud Messaging registration id expiration -


i using google cloud messaging android application , trying understand when registration id expires. this post able understand google tends refresh id @ time. curious how application know when id gets refreshed? if google decides refresh id , server till sending message old id dont think message sent. have try , register every time , see if ids same?

also same post says id refreshed when app version changes, on changing version through manifest registration id did not change. point on trying register again of version changes?

edit here server side. canonical id stored?

server side code:

<?php // message sent $message = $_post['message'];   // set post variables $url = 'https://android.googleapis.com/gcm/send';   $fields = array(                 'registration_ids'  => array($_post['registrationids']),                 'data'              => array( "message" => $message ),                 );   $headers = array(                      'authorization: key=' . $_post['apikey'],                     'content-type: application/json'                 );   // open connection $ch = curl_init();   // set url, number of post vars, post data curl_setopt( $ch, curlopt_url, $url );   curl_setopt( $ch, curlopt_post, true ); curl_setopt( $ch, curlopt_httpheader, $headers); curl_setopt( $ch, curlopt_returntransfer, true );   curl_setopt( $ch, curlopt_postfields, json_encode( $fields ) );   // execute post $result = curl_exec($ch);   // close connection curl_close($ch);   echo $result;   ?> 

i trying understand when registration id expires

gcm server refreshes(so old registration id expired) registration ids. when happens not documented anywhere. notified when happens.

how notified?

when send notification registration id expired, 1st time message(notification) delivered new registration id name canonical id. which mean, registration id sent message has been changed canonical id, change on server side well.


if google decides refresh id , server till sending message old id dont think message sent

like said, sent 1st time, after expiry.


also same post says id refreshed when app version changes

i don't think happens sure. if happens(registration id changes) same scenario explained above, need take care of canonical id.

edit

$result = curl_exec($ch); $result = json_decode($result); $canonical_ids_count = $result->canonical_ids; if($canonical_ids_count){     //update db replacing registration id      //the canonical id(new registration id) } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -