Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
WIKIPEDIA
/
imaliapi
/
app
/
Classes
:
PushNotificationBkp.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Classes; use Illuminate\Support\Facades\App; class PushNotificationBkp { private $icon; private $title; private $shortMsg; private $userFirebaseToken; private $clickAction; private $firebase_api_key; private $firebase_api_url; public function __construct( $title, $shortMsg, $userFirebaseToken, $clickAction = 'com.imali.payapp.payment_NOTICIA', $icon = 'ic_imali_logo_verde_01', ) { $this->title = $title; $this->shortMsg = $shortMsg; $this->userFirebaseToken = $userFirebaseToken; $this->clickAction = $clickAction; $this->icon = $icon; $this->firebase_api_key = env('FIREBASE_API_KEY'); $this->firebase_api_url = env('FIREBASE_URL'); } //? Send Push notification public function sendPush($data = array('sms' => '')) { $notification = array( // 'icon' => 'ic_i_mali_cover', // 'icon' => 'ic_imali_logo_verde_01', 'icon' => $this->icon, 'title' => $this->title, 'body' => $this->shortMsg, 'click_action' => $this->clickAction, 'color' => '#ffffff' ); $this->pushNotifification($this->userFirebaseToken, $notification, $data); } public function pushNotifification($token, $notification = array(), $data = array()) { // $apiKey = 'AAAA8zVzEPQ:APA91bHl_DXB6UGb_6gZlmFnaLTQoANtX_OBjvl3nOy2bSlnFhxedvk6EhGj7cZoIvmlbKeCnqGxXbuyMH_rEPuhRXvuitXzo6Pfl2TMXLar1PlifXqEhYq6tS55UMrY2Kffzj-P_UH-'; $apiKey = $this->firebase_api_key; $fields = array('to' => $token, 'notification' => $notification, 'data' => $data); $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json'); $url = $this->firebase_api_url; // $url = 'https://fcm.googleapis.com/fcm/send'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($curl); curl_close($curl); return json_decode($result, true); } // public function setLongMsg($longMsg){ // $this->longMsg = $longMsg; // } public function setShortMsg($shortMsg) { $this->shortMsg = $shortMsg; } public function setClickAction($clickAction) { $this->clickAction = $clickAction; } // public function setRoute($route){ // $this->route = $route; // } public function setTitle($title) { $this->title = $title; } public function setFirebaseToken($userFirebaseToken) { $this->userFirebaseToken = $userFirebaseToken; } }