<?php
class push_notification
{
public function notification($token,$titles,$message_q)
{
$tocken=$token;
$msg1=$message_q;
$t = $titles;
$this->pushmsg($tocken,$msg1,$t);
}
public function pushmsg($tocken,$msg1,$title)
{
$_REQUEST['token']=$tocken;
$msg = array
(
'body' => $msg1,
'title' => $title,
'vibrate' => 1,
'sound' => '',
'android_channel_id' =>'new_app',
'image' =>''
);
$fields = array
(
'to' => $_REQUEST['token'],
'notification' => $msg,
);
$headers = array
(
'Authorization: key=' . 'AAAAodj-cGo:APA91bGj8rHLt-_6vRbyBrB5LOlpPM0b_QGPIz7c1rlZgLeQBtXNzYptSLigoa4Tm4k_yjRsU8qQ9acSo3dWZ25erStc4r9tQUNbmL77iJuH43MCpBZFGPWr1qKcuCT5VRnothUM4v2w',
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/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, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
$result;
curl_close( $ch );
}
}
?>