#i am using chrome push notification word press plugin. it send notification at background side at android but i don't know the key to fetch response at android side.i had already "notification" "notifications" "data"..but don't work. please help me.
public function sendGCM($data) {
$this->putNotificationOnQueue($data);
$apiKey = get_option('web_push_api_key');
$url = 'http://ift.tt/YbbTRA';
$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;
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire