public function fcm_command($token,$command){
$path_to_fcm = 'https://fcm.googleapis.com/v1/projects/projects/messages:send';
//Taglock Server Key
$server_key = "";
$headers = array(
'Authorization:key=' .$server_key,
'Content-Type:application/json'
);
$fields = array('to'=>$token,'data'=>array('command'=>$command));
$payload = json_encode($fields);
$curl_session = curl_init();
curl_setopt($curl_session, CURLOPT_URL, $path_to_fcm);
curl_setopt($curl_session, CURLOPT_POST, true);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_session, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($curl_session, CURLOPT_POSTFIELDS, $payload);
$res = curl_exec($curl_session);
curl_close($curl_session);
return array('status'=>REST_Controller::HTTP_OK,'message'=> 'Command sent to device');
}
I am using old $server_key and only updated $path_to_fcm = 'https://fcm.googleapis.com/v1/projects/projects/messages:send';
, but notification not getting. Do I need to generate new server key or old is required?