$fcmUrl = 'https://fcm.googleapis.com/fcm/send';
$apikey = 'xxx';
$data = [
'attachment-url' =>$app_push->image,
'subText' => $app_push->subtext,
'title' =>$app_push->title,
'body' => $app_push->body
];
$fcmNotification = [
'priority'=>'high',
"content_available"=> true,
"mutable_content"=> true,
'to' => '/topics/ios_AppPushMessage',
"notification" => array(
"body" => $app_push->body,
"title" => $app_push->title,
"subtitle" => $app_push->subtext,
'sound' => 'default',
'badge' => '0'
),
'data' => $data
];
$headers = [
'Authorization: key=' . $apikey,
'Content-Type: application/json'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fcmUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));
$result = curl_exec($ch);
curl_close($ch);