I am sending a notification with the android php file, right now it is empty because I need to add channelID. How do I define Array to channelID? Empty notification going because of no channelID
<?php
sendNotification($title,$message,"android");
function sendNotification($title="",$message="",$type="android") {
$path_to_fcm = 'https://fcm.googleapis.com/fcm/send';
$server_key = "..";
if($type=="ios"){
// IOS KEY
$finalKey = array('..');
}else{
// ANROID KEY
$finalKey = array('..');
}
$headers = array(
'Authorization:key=' .$server_key,
'Content-Type : application/json');
$fields = array('to' => '/topics/...', 'notification'=>array('title'=>$title, 'message'=>$message));
$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);
curl_setopt($curl_session, CURLOPT_ENCODING, "");
curl_setopt($curl_session, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl_session, CURLOPT_TIMEOUT, 30);
curl_setopt($curl_session, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, "POST");
$result = curl_exec($curl_session);
if ($result === FALSE) {
die('Oops! FCM Send Error: ' . curl_error($curl_session));
}
curl_close($curl_session);
return json_decode($result,TRUE);
}