Arjun Choudhary Arjun Choudhary - 1 year ago 70
PHP Question

Android Push Notification not sending

I am trying to send push notification using

but push notification are not sent.
Now a days GCM id looks different is google change something in push notification process for eg (fRAvDRuNUU8:APA91bHvSGxi4AVPx2wGTFWb7OyAPPvXoIAcT).
Every time I get a json which is below give:

"multicast_id": 5873180458565135923,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
"error": "NotRegistered"

I tried so many code from internet but every time I get the same result.
The code I am using is working on so many other application perfectly.
Below is my code:

` public function sendMessageAndroid($registatoin_ids, $message){
$url = '';
$apiKey = "AIzaSyBf5vaONLbMyGdDoOEeC_MTTh9x1G4Qm-4";
$fields = array(
'registration_ids' => $registatoin_ids,//here my gcm id come in //array form array($device_id)
'data' => $message,//this is my message //$send_message['m']=array('msg'=>$message,'type'=>'chat');
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
$ch = curl_init();
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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
//die('Curl failed: ' . curl_error($ch));
return $result;

I tried everything with no luck. Please help.


Yes my problem is solved now.There were no mistake in my was my mobile developers mistake.Whenever you got response like this way below

` { 
       "multicast_id": 5873180458565135923, 
       "success": 0, 
       "failure": 1, 
       "canonical_ids": 0,
       "results": [ { "error": "NotRegistered" } 

` It is defiantly mistake in android code.