About FCM
This is way how to create Push Notification through Curl…
public functionsendFirebaseMessage ( $token, $title, $body)
{
$url = "https://fcm.googleapis.com/fcm/send";
//$token = "ctOQIjguuKk : APA91bEC90CqQUtaNNzVR-5JyDa4JXP5zfXGmLwM2i9djLobg1QSBlt5TkshNicqRQkY_Y773Ea4hDsoxP1zIWG76kjVQKmPfWZEfuLgvC289gNQEG64j39Ero6tlJne8w6DeqgJrIxg";
$serverKey = 'AAAAK7zk98I:APA91bH-TtQAIJkx3wivy4WYUiocQElVJewYKp9VHrcUcaxz-sWRu0byFKIqWWt3cPzsBZAK3FJSf-5UdiJs6ohv7qn44E1eH0c77T1I_El_cRl_rwuGN00H6M00wsffo7XNQwtJ4UdK';
//$title = "Notification title";
//$body = "Hello I am from Yourphp server";
$notification = array( 'title' =>$title, 'body' => $body, 'sound' => 'default', 'badge' => '1');
$arrayToSend = array( 'to' => $token, 'notification' => $notification, 'data' => $notification,'priority'=>'high');
$json = json_encode( $arrayToSend);
$headers = array( );
$headers[ ] = 'Content-Type: application/json';
$headers[ ] = 'Authorization: key='. $serverKey;
$ch = curl_init ();
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt( $ch, CURLOPT_POSTFIELDS, $json);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true) ;
//Send the request
$response = curl_exec( $ch);
}
The post Firebase Push Notification by Curl appeared first on IPHS TECHNOLOGIES.