title: send fcm notification and message using php
body: <p>I'm struggling with implementing notification using react-native-firebase</p>
  
  <p>The onNotification function is not called at all so I was almost crazy.</p>
  
  <p>But I think it might be on server problem.</p>
  
  <p>So I asked our php backend developer to give me server code related to fcm notification.</p>
  
  <p>I think it seems he's sending only message not notification.</p>
  
  <p>If it's right, how can I tell him to fix this function. and if it's not, I don't know what to do anymore..</p>
  
  <p>Please help me with your knowledge about this!</p>
  
  <p>Thank you guys!</p>
  
  <pre><code>function sendFCM($notif_array, $id) {
      $API_KEY = "api_key";
      $url = 'https://fcm.googleapis.com/fcm/send';
  
      $fields = array (
              'registration_ids' =&gt; array (
                      $id
              ),
              // 'data' =&gt; array (
              //         "message" =&gt; $message,
              //         "type" =&gt; $notif_type
              // )
              'content_available'=&gt;true,
              'priority'=&gt;'high',
              'data' =&gt; $notif_array
      );
      $fields = json_encode ( $fields );
  
      $headers = array (
              'Authorization: key=' . $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_RETURNTRANSFER, true );
      curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields );
  
      $result = curl_exec ( $ch );
      echo $result;
      curl_close ( $ch );
  }
  </code></pre>