title: Field is not a JSON array
body: <p>I'm getting the notification: "registration_ids" field is not a JSON array message received. Can any one help me solve this problem?</p>
  
  <p>If I put manually register code, then it works perfectly</p>
  
  <pre><code>function sendNotification($id_user, $msg_type) {
  
      define('API_ACCESS_KEY','AIzaSyDLJmlsR5Px8t4BoGqs1UsGPY1R8TmUIxI');
  
      $userData = mysql_query('SELECT * FROM tbl_users WHERE id = "'.$id_user.'"') or die(mysql_error());
  
      if(mysql_num_rows($userData) == 1) {
          $userData = mysql_fetch_array($userData);
          $message = $title = '';
  
          switch($msg_type) {
              case "new_order":
  
                  $title = "New order added.";
                  $message = "New order has been added by ".$userData["username"];
  
              break;
  
              default:
                  $message = $title = 'Default Message &amp; Title';
              break;
          }
  
          $msg = array
          (
              'message'   =&gt; $message,
              'title'     =&gt; $title,
              'subtitle'  =&gt; '',
              'tickerText'    =&gt; '',
              'vibrate'   =&gt; 1,
              'sound'     =&gt; 1,
              'largeIcon' =&gt; 'large_icon',
              'smallIcon' =&gt; 'small_icon'
          );
  
          $parentQuery = mysql_query('SELECT id_admin FROM tbl_user_relation WHERE id_user = "'.$id_user.'"') or die(mysql_error());
  
          if(mysql_num_rows($parentQuery) == 1) {
              $parentData = mysql_fetch_array($parentQuery);  
  
              $regQ = mysql_query('SELECT registration_id FROM tbl_users WHERE id = "'.$parentData['id_admin'].'" ') or die(mysql_error());
  
              if(mysql_num_rows($regQ) == 1) {
  
                  $parentData = mysql_fetch_array($regQ);
  
                  $fields = array
                  (
                      'registration_ids'  =&gt; $parentData,
                      'data'          =&gt; $msg
                  );
  
                  $headers = array
                  (
                      'Authorization: key=' . API_ACCESS_KEY,
                      'Content-Type: application/json'
                  );
  
                  $ch = curl_init();
                  curl_setopt( $ch, CURLOPT_URL , 'https://android.googleapis.com/gcm/send' );
                  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);
                  curl_close( $ch );
  
                  echo $result;
  
              }
          }
      }    
  }
  </code></pre>