Edit File: FirebaseV2.php
<?php namespace App\Traits; use FCM; use App\Models\UserToken ; use App\Models\SiteSetting; use Illuminate\Support\Facades\Log; use LaravelFCM\Message\OptionsBuilder; use LaravelFCM\Message\PayloadDataBuilder; use LaravelFCM\Message\PayloadNotificationBuilder; use Illuminate\Http\Exceptions\HttpResponseException; trait Firebase { public function sendNotification($tokens , $data) { // $firebaseToken = UserToken::where('user_id' , $user->id)->pluck('device_id')->all(); $SERVER_API_KEY = 'AAAAuvO3AM4:APA91bEbHSWzVs3FYkxXmeP22Pl0SZnAv25jOuCDYttSM1wp7MCw46XMkDIbH5XkGyDDdCScTQeCaSJgz0gXkPxlEOytEn0eAmfn-Ixf00zTxqhMJepklnRjdrLoIZQPYPrObvSN4Jls'; $data = [ "registration_ids" => $tokens, "notification" => [ "title" => $data['title_'.lang()], "body" => $data['message_'.lang()], "order_owner" => $data['order_owner']??'', 'sound' => true, ], 'data' => $data ]; $dataString = json_encode($data); $headers = [ 'Authorization: key=' . $SERVER_API_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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString); $response = curl_exec($ch); // Log::info($response); } }
Back to File Manager