Android推送通知未发送


Android Push Notification not sending

我试图使用cakephp发送推送通知,但推送通知未发送。现在,GCM id看起来不一样了,谷歌在推送通知过程中更改了一些东西,例如(fRAvDRuNUU8:APA91bHvSGxi4AVPx2wGTFWb7OyAppvXoAcT)。每次我得到一个json,下面给出:

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

我尝试了很多来自互联网的代码,但每次都得到相同的结果。我正在使用的代码正在完美地处理许多其他应用程序。以下是我的代码:

`    public function sendMessageAndroid($registatoin_ids, $message){
     $url = 'https://android.googleapis.com/gcm/send';
     $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));
    }        
   curl_close($ch);
   return $result;
}`

我什么都试过了,但运气不好。请帮忙。

是的,我的问题现在解决了。我的代码中没有错误。这是我的移动开发人员的错误。每当你在下面收到这样的回复时
` { 
       "multicast_id": 5873180458565135923, 
       "success": 0, 
       "failure": 1, 
       "canonical_ids": 0,
       "results": [ { "error": "NotRegistered" } 

`这是安卓代码中的公然错误。