Я пытаюсь отправить уведомление с помощью задания cron. Я перешел с GCM на FCM. На стороне сервера я изменил https://android.googleapis.com/gcm/send на https://fcm.googleapis.com/fcm/send, а также обновил информацию о том, как запрашивать изменение данных Registration_ids< /code> до. Проверка прохождения json: это действительный json, но у меня возникает ошибка. Поле «to» должно быть строкой JSON. Есть ли способ это решить?
Вот мой код
function sendNotificationFCM($apiKey, $registrationIDs, $messageText,$id) {
$headers = array(
'Content-Type:application/json',
'Authorization:key=' . $apiKey
);
$message = array(
'to' => $registrationIDs,
'data' => array(
"message" => $messageText,
"id" => $id,
),
);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://fcm.googleapis.com/fcm/send',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($message)
));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
Подробнее здесь: https://stackoverflow.com/questions/375 ... g-firebase