prepare($sql); $stmt->execute(); $inactiveUsers = $stmt->fetchAll(PDO::FETCH_ASSOC); $sentCount = 0; $fcmService = new FcmService(); // Assuming we have an FcmService or we can use sendFcmNotification directly if it's in functions.php // In Siro, encryptionHelper is typically used for tokens. Assuming it's required here: require_once __DIR__ . '/../core/Security/EncryptionHelper.php'; $encryptionHelper = new EncryptionHelper(); foreach ($inactiveUsers as $user) { $passengerId = $user['passenger_id']; $encryptedToken = $user['token']; $decryptedToken = $encryptionHelper->decryptData($encryptedToken); if ($decryptedToken) { // Send a silent push notification. // A silent push doesn't have a 'notification' payload (title/body), // it only has a 'data' payload with 'content-available' => 1 for iOS. $dataPayload = [ 'type' => 'location_sync_request', 'action' => 'wake_up' ]; // This is a pseudo implementation relying on your existing push notification setup. // Ensure that your FCM implementation correctly maps 'content-available' for iOS. sendSilentFcmNotification($decryptedToken, $dataPayload); $sentCount++; } } echo "Silent Push triggered for $sentCount inactive users.\n"; /** * Helper to send Silent FCM */ function sendSilentFcmNotification($token, $data) { if (function_exists('sendFCM_Internal')) { return sendFCM_Internal($token, '', '', $data, 'SilentPush', false, 'silent'); } if (!class_exists('FcmService')) { require_once __DIR__ . '/../core/Services/FcmService.php'; } $fcm = new FcmService(); return $fcm->send($token, '', '', $data, 'SilentPush', 'silent'); } ?>