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;

0 comments:
Post a Comment