【发布时间】:2017-08-24 11:10:27
【问题描述】:
我正在从我的服务器向特定主题的 firebase 发送一条消息,我返回一个 id,但是当我从控制台向通知到达的主题执行此操作时,它没有收到应用程序的通知。
我应该如何针对特定主题执行此操作,但这是一个通知?
PHP:
<i>
<?php
function send_notification ($message)
{
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'to' => "/topics/news",
'data' => $message
);
$headers = array(
'Authorization: key=AAAApDF81wE:APA91bG7g.....',
'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;
}
$message = array("message" => " FCM PUSH NOTIFICATION TEST MESSAGE");
$message_status = send_notification($message);
echo $message_status;
?>
</i>
我刚刚改了这个
$fields = 数组(
'to' => "/topics/news",
'notification' => $message
);
【问题讨论】:
-
嗨卡罗来纳。您是否尝试过发送
notification消息负载? -
是这个...'to' => "/topics/news", 'notification' => $message
-
但是消息是否包含正确的参数?如果您使用详细信息编辑您的帖子,我们会更容易看到。
标签: php android firebase firebase-cloud-messaging