We have a push-android notification binding in the response-native for the last 2 weeks, and we also tried with the following to respond to our own module
https://www.npmjs.com/package/react-native-push-notification
Using the above module, we can get a local notification (static application) that works, but the notification from the server is not displayed. we tried " https://github.com/oney/react-native-gcm-android " this also ..
The ability to register with GCM and receive a token from GCM, but using this registered token, cannot receive a notification and
we use php to send notifications from the server, and the php code below
This is the code we use to send notifications from the server,
<?php
function sendPushNotificationToGCM($registatoin_ids, $message) {
$url = 'https://android.googleapis.com/gcm/send';
$fields = array('registration_ids' => $registatoin_ids, 'data' => array("title" => 'hi', "message" => $message, ), );
define("GOOGLE_API_KEY", "YOUR API KEY");
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'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_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
return $result;
}
?>
How can we overcome this?