
Я хочу добавить изображение для push-уведомления.Я использую Firebase и приложение разработано с использованием ионных 3 фреймворков.У меня есть веб-приложение для отправки уведомлений.это код PHP.Пожалуйста, помогите мне добавить изображение для push-уведомления.
public function pushNotification($title, $body, $image) {
//FCM API end-point
$url = 'https://fcm.googleapis.com/fcm/send';
//api_key available in Firebase Console -> Project Settings -> CLOUD MESSAGING -> Server key
$server_key = 'xxxx';
$target = [];
$targets = $this->db->get('device_ids')->result();
foreach($targets as $val) {
array_push($target, $val->device_id);
}
$fields = array();
$fields['notification'] = array(
'title' => $title,
'body' => $body
);
if(is_array($target)){
$fields['registration_ids'] = $target;
}else{
$fields['to'] = 'news';
}
//header with content_type api key
$headers = array(
'Content-Type:application/json',
'Authorization:key='.$server_key
);
//CURL request to route notification to FCM connection server (provided by Google)
$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);
if ($result === FALSE) {
die('Oops! FCM Send Error: ' . curl_error($ch));
}
curl_close($ch);
print_r(json_encode($fields));
}