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