add new features like realtime 2026-05-29-17

This commit is contained in:
Hamza-Ayed
2026-05-29 17:06:03 +03:00
parent ac5f73958e
commit f89b04f614
3 changed files with 41 additions and 14 deletions

View File

@@ -93,25 +93,31 @@ try {
curl_close($ch);
// ب) FCM (باستخدام الدالة الجديدة مع فك التشفير)
$stmtToken = $con->prepare("SELECT token FROM driverToken WHERE captain_id = ?");
$stmtToken->execute([$driverId]);
$rawToken = $stmtToken->fetchColumn();
$driverToken = filterRequest("driver_token");
if ($rawToken) {
$driverToken = $rawToken;
// 🔥 محاولة فك التشفير (لأن التوكنات غالباً مشفرة)
if (!empty($encryptionHelper)) {
try {
$decrypted = $encryptionHelper->decryptData($rawToken);
if ($decrypted !== false && !empty($decrypted)) {
$driverToken = trim($decrypted);
if (empty($driverToken)) {
$stmtToken = $con->prepare("SELECT token FROM driverToken WHERE captain_id = ?");
$stmtToken->execute([$driverId]);
$rawToken = $stmtToken->fetchColumn();
if ($rawToken) {
$driverToken = $rawToken;
// 🔥 محاولة فك التشفير (لأن التوكنات غالباً مشفرة)
if (!empty($encryptionHelper)) {
try {
$decrypted = $encryptionHelper->decryptData($rawToken);
if ($decrypted !== false && !empty($decrypted)) {
$driverToken = trim($decrypted);
}
} catch (Exception $e) {
// في حال الفشل نستخدم الخام
}
} catch (Exception $e) {
// في حال الفشل نستخدم الخام
}
}
}
if (!empty($driverToken)) {
// تجهيز البيانات
$fcmData = [
'category' => 'Cancel Trip',