Answer the question
In order to leave comments, you need to log in
Why are push notifications not being delivered?
Good afternoon.
On site X, I implemented push notifications using firebase. Initialization, obtaining a token - everything works. However, there were problems with sending push notifications and their delivery.
The send script looks like this:
$notification = [
'title' => 'Title',
'body' => 'Text',
'click_action' => 'https://site.ru',
];
$ids = [
// токены
];
$key = '###key###';
$headers = array(
"Content-Type: application/json",
"Authorization: key={$key}"
);
$postData = json_encode(array(
'notification' => $notification,
'registration_ids' => $ids,
"priority" => "high"
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "https://fcm.googleapis.com/fcm/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
Answer the question
In order to leave comments, you need to log in
what am I doing wrong
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question