Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function sendNotification($registrationIds,$title,$message)
- {
- $msg = array
- (
- 'body' => $message,
- 'title' => $title,
- 'vibrate' => 1,
- 'sound' => 'default',
- 'largeIcon' => 'large_icon',
- 'smallIcon' => 'small_icon'
- );
- $fields = array
- (
- //in array ['23143252','329AJK398420380]
- 'registration_ids' => $registrationIds,
- 'notification' => $msg
- );
- $headers = array
- (
- //server-key firebase
- 'Authorization: key=' . config('firbase.server_key'),
- '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 );
- curl_close( $ch );
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement