【发布时间】:2020-07-27 19:46:14
【问题描述】:
我尝试使用 firebase 通知控制台发送通知,它工作正常,但使用代码会引发错误 {"multicast_id":469219618584251399,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} 我的代码:-
<?php
define('API_ACCESS_KEY','Server key');
'to' => $token, //single token
'notification' => $notification,
'data' => $extraNotificationData
];
$headers = [
'Authorization: key=API_ACCESS_KEY',
'Content-Type: application/json'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fcmUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
【问题讨论】:
标签: php firebase push-notification firebase-cloud-messaging