/
memoryspeak
/
MemoryspeakServer
Обзор
Документация
Войти
/
memoryspeak
/
MemoryspeakServer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
controllers/FcmController.php
40 строк
1 KB
memoryspeak
refactor update fcm token
14 дек 2025, 06:58
14 дек 2025, 06:58
a4ed920
Код
Авторство
О чём код?
<?php class FcmController { private $database; private $userId; private $deviceInfo; private $platform; public function __construct($database, $userId, $deviceInfo, $platform) { try { $this->database = $database; $this->userId = $userId; $this->deviceInfo = $deviceInfo; $this->platform = $platform; } catch(PDOException $e) { LoggerService::write(debug_backtrace(), $e->getMessage()); throw $e; } } public function updateFcmToken($fcmToken) { try { $isTokenExist = $this->database->getFcmTokenIdByUserIdAndFcmToken($this->userId, $fcmToken); $tokenId = $isTokenExist['id']; if ($isTokenExist) { $this->database->activateFcmToken($tokenId, $this->deviceInfo, $this->platform); } else { $this->database->deactivateFcmTokenByUserId($this->userId); $this->database->createFcmToken($this->userId, $fcmToken, $this->deviceInfo, $this->platform); } } catch(PDOException $e) { LoggerService::write(debug_backtrace(), $e->getMessage()); throw $e; } } } ?>