2
我想創建應用程序的通知。通知必須從php文件發送到firebase然後發送到設備。起初,我試圖用firebase控制檯發送,它的工作原理非常完美。但是,當我嘗試使用PHP發送notificaion然後我有問題。它說成功發佈了,但我沒有收到任何通知。還有就是我發送通知PHP:ios發送與firebase通知
<?php
function send_notification ($tokens, $message)
{
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'to' => $tokens,
'data' => $message
);
$headers = array(
'Authorization:key = my api key',
'Content-Type: application/json'
);
$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('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
return $result;
}
$data = array("alert" => "How it is going today");
$token = "fJVM7YrWGQg......";
$message = array("message" => " FCM PUSH NOTIFICATION TEST MESSAGE");
$message_status = send_notification($token, $message);
echo $message_status;
>
...我已經尋找解決它。但沒有任何幫助。
嗨@MRustamzade可以告訴我,請你如何處理它內的應用程序。謝謝,請讓我知道。 –
@AvinashMishra我也是這樣做的:https://firebase.google.com/docs/cloud-messaging/ios/client – MRustamzade