php android推送通知未送达所有人
我在这里读了一些关于这个问题的文章,但似乎没有解决它,不确定我遗漏了什么,这是我的代码,应该向所有设备发送通知,但它似乎遗漏了一些,任何帮助都非常感谢:php android推送通知未送达所有人,android,cordova,push,google-cloud-messaging,Android,Cordova,Push,Google Cloud Messaging,我在这里读了一些关于这个问题的文章,但似乎没有解决它,不确定我遗漏了什么,这是我的代码,应该向所有设备发送通知,但它似乎遗漏了一些,任何帮助都非常感谢: foreach ($devices as $deviceArray) { $regIds[] = $deviceArray['device_id']; } $pusher->notify($regIds, $msg); 通知功能: public function notify($regIds, $data) {
foreach ($devices as $deviceArray) {
$regIds[] = $deviceArray['device_id'];
}
$pusher->notify($regIds, $msg);
通知功能:
public function notify($regIds, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, self::GOOGLE_GCM_URL);
if (!is_null($this->proxy)) {
curl_setopt($ch, CURLOPT_PROXY, $this->proxy);
}
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHeaders());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getPostFields($regIds, $data));
$result = curl_exec($ch);
if ($result === false) {
throw new \Exception(curl_error($ch));
}
curl_close($ch);
$this->output = $result;
}
private function getHeaders()
{
$tempArray[0] = 'Authorization: key=' . $this->apiKey;
$tempArray[1] = 'Content-Type: application/json';
return $tempArray;
}
private function getPostFields($regIds, $data)
{
$fields = array(
'registration_ids' => is_string($regIds) ? array($regIds) : $regIds,
'data' => is_string($data) ? array( 'message' => $data) : $data,
);
return json_encode($fields, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
}
你的服务器从谷歌得到了什么样的响应?我该如何检查?我通常不会得到任何
$result
应该包含JSON响应的内容。