Update: 2026-07-02 15:35:12
This commit is contained in:
@@ -539,6 +539,23 @@ function sendFCM_Internal(
|
||||
return $fcm->send($target, $title, $body, is_array($customData) ? $customData : [], $category, $tone);
|
||||
}
|
||||
|
||||
// 🆕 دالة ذكية لإرسال وإرساء إشعارات السائقين في قاعدة البيانات (لضمان بقائها حتى لو لم يقرأها)
|
||||
function sendAndSaveDriverNotification($con, $driver_id, $token, $title, $body, $customData = [], $category = 'System', $tone = 'ding') {
|
||||
// 1. حفظ في قاعدة البيانات (لتظهر في صفحة الإشعارات داخل التطبيق)
|
||||
try {
|
||||
$stmt = $con->prepare("INSERT INTO notificationCaptain (driverID, title, body) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$driver_id, $title, $body]);
|
||||
} catch (Exception $e) {
|
||||
error_log("[sendAndSaveDriverNotification] DB Save Error: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// 2. إرسال Push Notification
|
||||
if (!empty($token) && $token !== 'all') {
|
||||
return sendFCM_Internal($token, $title, $body, $customData, $category, false, $tone);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function logAudit($con, $adminId, $action, $tableName = null, $recordId = null, $details = null) {
|
||||
|
||||
Reference in New Issue
Block a user