php firebase推送通知成功响应但未显示
我使用PHP cURL作为iOS应用程序上推送通知的触发器。来自FCM端点的响应返回消息ID,我认为这是成功的,但设备上没有显示通知 当我尝试从云消息页面手动发送通知时,我可以在设备上接收通知 这就是我试图从PHP发送通知的方式。我正在使用firebase文档中的HTTP v1 APIphp firebase推送通知成功响应但未显示,php,firebase,push-notification,firebase-cloud-messaging,Php,Firebase,Push Notification,Firebase Cloud Messaging,我使用PHP cURL作为iOS应用程序上推送通知的触发器。来自FCM端点的响应返回消息ID,我认为这是成功的,但设备上没有显示通知 当我尝试从云消息页面手动发送通知时,我可以在设备上接收通知 这就是我试图从PHP发送通知的方式。我正在使用firebase文档中的HTTP v1 API <?php $accessToken = 'ya29.this-is-the-oAuth-access-token'; $token = 'this-is-the-device-token'; $ur
<?php
$accessToken = 'ya29.this-is-the-oAuth-access-token';
$token = 'this-is-the-device-token';
$url = 'https://fcm.googleapis.com/v1/projects/my-project-id/messages:send';
$notif = array(
'title' => 'Test notification',
'body' => 'Sample notification from FCM',
'image' => "https://my-domain.com/images/favicon.png",
);
$fields = json_encode(['message' => ['token' => $token,'notification' => $notif]]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($fields));
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$accessToken;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}else{
echo $result;
}
curl_close($ch);
?>