php - MissingRegistraton error when trying to send data to GCM -


i've searched lot couldn't find solution question.

i'm using php server , trying send pushnotifications android app. when i'm trying out code in browser error: "error=missingregistration".

here code run:

registration_ids = array($regid);         $message = array(             'hangmessage' => $message,             'userid' => $user_id             );          $result = $gcm->send_notification($registration_ids, $message); 

and code call:

$url = "https://android.googleapis.com/gcm/send";      $fields = array(         'registration_ids' => $regisration_ids,         'data' => $message,         );      $headers = array(         'authorization: key=' . google_api_key,         '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_httpheader, $headers);     curl_setopt($ch, curlopt_returntransfer, true);      //disabling ssl certificate support temporarly     curl_setopt($ch, curlopt_ssl_verifypeer, false);      curl_setopt($ch, curlopt_postfields, json_encode($fields));      //execute psot     $result = curl_exec($ch);     if($result == false){         die('curl failed: ' . curl_error($ch));     }      //close connection     curl_close($ch);     echo $result; 

the request doesn't come way server according google apis console report system.

anyone have idea wrong?

your request should :

content-type:application/json authorization:key=aizasyb-1ueai2wiuapxcs2q0gzyzpu7udno5aa  {   "registration_ids" : ["apa91bhun4mxp5egokmwt2kzfbafuh-1ryqx..."],   "data" : {     ...   }, } 

therefore believe error might in line :

'content-type= application/json' 

try change = :.

since content type header invalid, gcm server may assume default value content type (which might application/x-www-form-urlencoded;charset=utf-8, in case registration id requires different key, explain missingregistration error).

btw, fact missingregistraton error means request reach gcm server. gcm requests not logged in google apis console report system.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -