From 12fc64dc9abe433374c57a0dfbbb9a35b289c59a Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 1 Aug 2026 02:06:59 +0300 Subject: [PATCH] Update: 2026-08-01 02:06:59 --- .../lib/controller/functions/location_controller.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/siro_driver/lib/controller/functions/location_controller.dart b/siro_driver/lib/controller/functions/location_controller.dart index 2979e86e..2b9b4ae0 100755 --- a/siro_driver/lib/controller/functions/location_controller.dart +++ b/siro_driver/lib/controller/functions/location_controller.dart @@ -230,10 +230,15 @@ class LocationController extends GetxController with WidgetsBindingObserver { // إيقاف خدمة الخلفية BackgroundServiceHelper.stopService(); - if (socket == null || (!socket!.connected && !_isInitializingSocket)) { - Log.print("🔄 Initializing Socket on resume..."); - initSocket(); + // 🔥 Fix: iOS silently kills WebSockets in background. + // The socket_io_client might still report 'connected' as true for ~20s. + // We MUST force a disconnect so initSocket() properly creates a fresh connection + // and immediately emits 'get_pending_orders' to catch missed FCM payloads. + if (socket != null) { + socket!.disconnect(); } + initSocket(); + } else if (state == AppLifecycleState.paused || state == AppLifecycleState.detached) { Log.print("📱 Lifecycle: App is in BACKGROUND");