php - GCM not show content on device -


i try push notification android device php. when insert text text field , send android device. sent success no content in message on device.why? , how fix it? php code:

<?php include('config/dbconnect_log.php'); if(isset($_post['submit'])){ function sendpushnotification($registration_ids, $message) {      $url = 'https://android.googleapis.com/gcm/send';     $fields = array(         'registration_ids' => $registration_ids,         'data' => $message,     );      define('google_api_key', 'my google api key');      $headers = array(         'authorization:key=' . google_api_key,         'content-type: application/json'     );     echo json_encode($fields);     $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_ssl_verifypeer, false);     curl_setopt($ch, curlopt_postfields, json_encode($fields));      $result = curl_exec($ch);     if($result === false)         die('curl failed ' . curl_error());      curl_close($ch);     return $result;  }  $pushstatus = '';      $query = "select distinct googleid ggevent";     if($query_run = mysql_query($query)) {          $gcmregids = array();         $i = 0;         while($query_row = mysql_fetch_assoc($query_run)) {             $i++;             $gcmregids[floor($i/1000)][] = $query_row['googleid'];         }      }     $pushmessage = $_post['message'];     if(isset($gcmregids) && isset($pushmessage)) {          $message = array('msg' => $pushmessage);         $pushstatus = array();         foreach($gcmregids $val) $pushstatus[] = sendpushnotification($val, $message);      }     } ?>  <html>     <head>      </head>     <body>   <article class="module width_full">     <form method = 'post' action = ''>         <fieldset>             <label>content</label>             <textarea rows = 2 name = "message"  placeholder = 'messages transmit via gcm'></textarea>         </fieldset>         <div class="clear"></div>                 </div>             <footer>                 <div class="submit_link">                     <input type="submit" name='submit' value="send push notification" class="alt_btn">                 </div>             </footer>     </form>     </article>      </body> </html> 

first register device gcm , gcm key. send notification device manually using gcm key. curl request is

curl --header "authorization: key=" --header content-type:"application/json" https://android.googleapis.com/gcm/send -xpost -d '{"data":{"new message through curl"},"registration_ids":["apa91bge-ihcjil6yxglnetf1fzcvcrgcn35rtoshprk7mxoz70tp6jmnichlxmibld642cwgo0fem9xreca2ukvavnyfny7hcj0jcxtinbxnn5pml9yqiu6qwrvq4v8gie4ozv4vjoc"]}' 

if notification using device has been registered successfully

for more info , detailed working classed test go through following link

gcm php (google cloud messaging)


Comments

Popular posts from this blog

What Are The Best Universities In The World?

Hard vs. Soft Water: What's The Difference?

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -