Answer the question
In order to leave comments, you need to log in
Why is event.data null when sending a push notification?
Send notification via GCM
$msg = array(
'title' => 'This is a title. title',
'message' => 'here is a message. message',
);
$fields = array(
'registration_ids' => $r,
'data' => $msg,
);
$headers = array(
'Authorization: key=' . $gcm_auth_key,
'Content-Type: application/json',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ' https://android.googleapis.com/gcm/send ');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
self.addEventListener('push', function(event) {
console.log(event);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question