Android-Firebase Push Notification when app is in background
<p>I am developing Firebase push notification using Server API call in Android application.it works perfectly when application is in foreground but when application is not in foreground i am not able to get the push notification.</p>

<p>I am sending JSON data in which header contains Server API key and content type and the value contains data which have body as array. Appreciate any help.</p>

<p>PHP code:</p>

<pre><code> $url = 'https://fcm.googleapis.com/fcm/send';
 $fields =array('registration_ids' =&gt; $tokens,'data' =&gt; $message); 
 $headers = array('Authorization:key = value','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_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); 
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); 
$result = curl_exec($ch);?&gt;
</code></pre>