0

I am sending pushnotification to android devices from a php server,but some devices didn't get the pushnotification.

Here is the status from server

{"multicast_id":4893937277293136804,"success":4,"failure":10,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"message_id":"0:1452592669440333%c40440a4f9fd7ecd"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"message_id":"0:1452592669442897%c40440a4f9fd7ecd"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"message_id":"0:1452592669442899%c40440a4f9fd7ecd"},{"error":"NotRegistered"},{"error":"NotRegistered"},{"message_id":"0:1452592669442901%c40440a4f9fd7ecd"}]}

PHP

$key="XXXXXX";
  $url = 'https://android.googleapis.com/gcm/send';
  $fields = array(
                'registration_ids'  =>$result,
                'data'              => array( "message" =>$msg,"title"=>$title,"soundname"=>"beep.wav" ),
                );
  $headers = array(
                    'Authorization: key=' . $key,
                    'Content-Type: application/json'
                );
 try{
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  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 ) );
  $res = curl_exec($ch);
  print_r($res)
  }

From the response only 4 devices successfully get the response,but 10 failures is occurred.

Whats is the problem?

shamon shamsudeen
  • 5,466
  • 17
  • 64
  • 129

1 Answers1

0

One of these could be the problem why you are getting NotRegistered. See Downstream message error response codes.

Unregistered Device 200 + error:NotRegistered

An existing registration token may cease to be valid in a number of scenarios, including:

  • If the client app unregisters with GCM.
  • If the client app is automatically unregistered, which can happen if the user uninstalls the application. For example, on iOS, if the APNS Feedback Service reported the APNS token as invalid.
  • If the registration token expires (for example, Google might decide to refresh registration tokens, or the APNS token has expired for iOS devices).
  • If the client app is updated but the new version is not configured to receive messages.

For all these cases, remove this registration token from the app server and stop using it to send messages.

Community
  • 1
  • 1
gerardnimo
  • 1,444
  • 8
  • 10