Skip to content

Instantly share code, notes, and snippets.

@alamsyahh15
Created December 8, 2021 05:09
Show Gist options
  • Save alamsyahh15/3fd4e4e9e4c56af16361f653f2900bbd to your computer and use it in GitHub Desktop.
Save alamsyahh15/3fd4e4e9e4c56af16361f653f2900bbd to your computer and use it in GitHub Desktop.
public function sendNotification($arrToken = array(), $title = null, $body=null, $type=null, $data = null){
$response = Http::withHeaders(array(
'Authorization' => 'key=AAAAAihLhJI:APA91bGKKkamUmF14q3v4ZqJs3Kz6d2CKGsoTGoFL-6Al30yw0rz4VSzeQn4Gewtqt2q5GE9GHd9pFn3O1D_xG_ys8FUKjWn7V5SK4f563Tjp1xh10-CgQVFD-AqrQOPdyYKYGbF6uVU',
'Content-Type' => 'application/json'
))->post('https://fcm.googleapis.com/fcm/send',array(
'registration_ids' => $arrToken,
'notification' => array(
'title' => "{$title}",
'body' => "{$body}",
'sound' => 'default'
),
'data' => array(
"sound" => "default",
"type" => $type,
'data' => $data,
),
));
return json_decode($response->body());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment