. */ namespace App\Libraries; use Illuminate\Support\Facades\Log; class FlexisipPusherConnector { private $pusherPath; private $pnProvider; private $pnParam; private $pnPrid; public function __construct(string $pnProvider, string $pnParam, string $pnPrid) { $this->pusherPath = config('app.flexisip_pusher_path'); $this->pnProvider = $pnProvider; $this->pnParam = $pnParam; $this->pnPrid = $pnPrid; if ($this->pnProvider == 'fcm' && config('app.flexisip_pusher_firebase_key') == null) { Log::error('Firebase pusher key not configured'); } } public function sendToken(string $token) { $payload = json_encode(['token' => $token]); if (!empty($this->pusherPath)) { $command = $this->pusherPath . " --pn-provider '" . $this->pnProvider . "'" . " --pn-param '" . $this->pnParam . "'" . " --pn-prid " . $this->pnPrid . " --customPayload '" . $payload . "'"; $command .= in_array($this->pnProvider, ['apns', 'apns.dev']) ? " --apple-push-type Background" : " --key " . config('app.flexisip_pusher_firebase_key'); $output = null; $retval = null; return exec($command, $output, $retval); } Log::error('Pusher path not configured'); } }