Thursday, January 31, 2019

How can I send a Firebase Cloud Messaging notification without use the Firebase Console?

FCM cloud message notification send mobile device on simple method try this code

$ch = curl_init();
$registration_ids="YOUR DEVICE ID";
ignore_user_abort();
ob_start();
$url = 'https://fcm.googleapis.com/fcm/send';
$message = 'Name:"Vengadeshwaran" Contact number:"888XXXX-XXX"';
$fields = array(
'registration_ids' => array($registration_ids),
'priority' => 10,
'notification' => array('title' => 'Birthday', 'body' => $message ,'sound'=>'Default'),
);
$google_api_key = 'WEB API KEY';
$headers = array(
'Authorization:key='.$google_api_key,
'Content-Type: application/json'
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$status = curl_exec($ch);
curl_close($ch);
echo $status;

Related Posts:

  • XML to string in php Input: <list version="1.0"> <meta> <type>resource-list</type> </meta> <resources start="0" count="188"> <resource classname="Quote"> <fiel… Read More
  • How to remove ninja slider trial version text How to remove ninja slider trial version text Find this code for Ninja slider Js file return a.replace(/(?:.*\.)?(\w)([\w\-])?[^.]*(\w)\.[^.]*$/, "$1$3$2") Replace to return null … Read More
  • Whoops, it looks like you have an invalid PHP version. As far as I can see it could be one of the following things: 1) Corrupt index.php in your magento root dir. 2) Incorrect virtual host set up resulting in php not executing the code in index.php Could you post your apache… Read More
  • XML to Array in php Input: <list version="1.0"> <meta> <type>resource-list</type> </meta> <resources start="0" count="188"> <resource classname="Quote"> <… Read More
  • Ionic 3 Multiple Select date from Calendar Support date range. Support multi date. Support HTML components. Disable weekdays or weekends. Setting days event. Setting localization. Material design. Support ionic-angular ^3.0.0 Demo live demo click me.… Read More

0 comments:

Post a Comment