"registration_ids" field is not a JSON array (Firebase)
<p>I am facing problem with Firebase "registration_ids". When I send the request from Rest Client i get the successful response.</p>

<pre><code>{"multicast_id":4650719213012935695,"success":2,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1468837777484579%214918aff9fd7ecd"},{"message_id":"0:1468837777484484%214918aff9fd7ecd"}]}
</code></pre>

<p>But when I call same php script from my Android application it gives me error in the response. (I got the response in Charles Proxy)</p>

<pre><code>"registration_ids" field is not a JSON array
</code></pre>

<p>Here is my php script</p>

<pre><code>function fetchFirebaseTokenUsers($message) {       
    $query = "SELECT token FROM firebase_tokens";
    $fcmRegIds = array();
    if($query_run = mysqli_query($this-&gt;con, $query)) {         
        while($query_row = mysqli_fetch_assoc($query_run)) {
            array_push($fcmRegIds, $query_row['token']);
        }
    }

    if(isset($fcmRegIds)) {
        $pushStatus = $this-&gt;sendPushNotification($fcmRegIds, $message);
    }
}

function sendPushNotification($registration_ids, $message) {

    ignore_user_abort();
    ob_start();

    $url = 'https://fcm.googleapis.com/fcm/send';

    $fields = array(
        'registration_ids' =&gt; $registration_ids,
        'data' =&gt; $message,
    );

    define('GOOGLE_API_KEY', 'AIzaSyC.......VdYCoD8A');

    $headers = array(
        'Authorization:key='.GOOGLE_API_KEY,
        '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_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;
    ob_flush();
}
</code></pre>