Ich benutze Chrome Push-Benachrichtigung Wort drücken Plugin. Es sendet eine Benachrichtigung auf der Hintergrundseite bei Android, aber ich weiß nicht den Schlüssel zum Abrufen der Antwort auf der Android-Seite. Ich hatte bereits "Benachrichtigung" "Benachrichtigungen" "Daten" .. Aber sie haben nicht funktioniert. Bitte hilf mir.Schlüssel zu holen Antwort von Chrome Push-Benachrichtigung auf Android-Seite
public function sendGCM($data)
{
$this->putNotificationOnQueue($data);
$apiKey = get_option('web_push_api_key');
$url = 'https://android.googleapis.com/gcm/send';
$id = $this->getClientIds();
if (empty($id)) {
return 'No subscribers on your site yet!';
}
if (count($id) >= 1000) {
$newId = array_chunk($id, 1000);
foreach ($newId as $inner_id) {
$fields = array(
'registration_ids' => $inner_id,
);
$headers = array(
'Authorization: key=' . $apiKey,
'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_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
//print_r($result);
}
} else {
$fields = array(
'registration_ids' => $id,
);
$headers = array(
'Authorization: key=' . $apiKey,
'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_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
}
$answer = json_decode($result);
curl_close($ch);
if ($answer) {
$this->cleanClientIds($answer);
}
return $result;
}
foreach ($ newid wie $ inner_id) { $ Felder = Array ( 'registration_ids' => $ inner_id, 'data' => $ Daten); $ headers = array ( 'Autorisierung: key ='. $ ApiKey, 'Content-Type: application/json'); } –