diff --git a/siro_admin/lib/constant/links.dart b/siro_admin/lib/constant/links.dart index d9f35810..243df860 100644 --- a/siro_admin/lib/constant/links.dart +++ b/siro_admin/lib/constant/links.dart @@ -51,8 +51,7 @@ class AppLink { case 'Egypt': return 'https://location-egypt.siromove.com/siro/ride/location'; case 'Jordan': - // TODO: Change to new subdomain when fully migrated - return 'https://location.intaleq.xyz/intaleq/ride/location'; + return 'https://jordan-siro.intaleqapp.com/loction_server/siro/ride/location'; default: return 'https://location.siromove.com/siro/ride/location'; } diff --git a/siro_admin/lib/controller/auth/otp_helper.dart b/siro_admin/lib/controller/auth/otp_helper.dart index ac16b447..da8e633b 100644 --- a/siro_admin/lib/controller/auth/otp_helper.dart +++ b/siro_admin/lib/controller/auth/otp_helper.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:jwt_decoder/jwt_decoder.dart'; import 'package:get/get.dart'; @@ -17,10 +19,8 @@ import '../functions/crud.dart'; import '../functions/encrypt_decrypt.dart'; class OtpHelper extends GetxController { - static final String _sendOtpUrl = - '${AppLink.server}/auth/otp/request.php'; - static final String _verifyOtpUrl = - '${AppLink.server}/auth/otp/verify.php'; + static final String _sendOtpUrl = '${AppLink.server}/auth/otp/request.php'; + static final String _verifyOtpUrl = '${AppLink.server}/auth/otp/verify.php'; static final String _checkAdminLogin = '${AppLink.server}/Admin/auth/login.php'; @@ -185,7 +185,13 @@ class OtpHelper extends GetxController { await box.write(BoxName.phoneVerified, true); await box.write('admin_password', password); - FirebaseMessaging.instance.subscribeToTopic('admin_alerts'); + if (Platform.isAndroid || Platform.isIOS) { + try { + FirebaseMessaging.instance.subscribeToTopic('admin_alerts'); + } catch (e) { + Log.print('FCM Subscribe error: $e'); + } + } mySnackbarSuccess('تم تسجيل الدخول بنجاح'); return true; @@ -241,7 +247,13 @@ class OtpHelper extends GetxController { String token = r(rawJwt.toString()).split(AppInformation.addd)[0]; if (!JwtDecoder.isExpired(token)) { Log.print('Valid JWT found, skipping login.php (no OTP needed)'); - FirebaseMessaging.instance.subscribeToTopic('admin_alerts'); + if (Platform.isAndroid || Platform.isIOS) { + try { + FirebaseMessaging.instance.subscribeToTopic('admin_alerts'); + } catch (e) { + Log.print('FCM Subscribe error: $e'); + } + } Get.offAll(() => const AdminHomePage()); return; } @@ -279,7 +291,13 @@ class OtpHelper extends GetxController { } else if (response['jwt'] != null) { box.write(BoxName.jwt, c(response['jwt'])); } - FirebaseMessaging.instance.subscribeToTopic('admin_alerts'); + if (Platform.isAndroid || Platform.isIOS) { + try { + FirebaseMessaging.instance.subscribeToTopic('admin_alerts'); + } catch (e) { + Log.print('FCM Subscribe error: $e'); + } + } try { if (Get.isRegistered()) { Get.find().getDashBoard(); diff --git a/siro_driver/lib/controller/firebase/firbase_messge.dart b/siro_driver/lib/controller/firebase/firbase_messge.dart index 5157162d..0b72bbda 100755 --- a/siro_driver/lib/controller/firebase/firbase_messge.dart +++ b/siro_driver/lib/controller/firebase/firbase_messge.dart @@ -154,15 +154,21 @@ class FirebaseMessagesController extends GetxController { driverToken = myList[14].toString(); Get.put(HomeCaptainController(), permanent: true).changeRideId(); update(); - Get.toNamed('/OrderRequestPage', arguments: { - 'myListString': myListString, - 'DriverList': myList, - 'body': body, - 'is_destination_match': message.data['is_destination_match'] ?? '0', - // 🆕 "أرباحك أعلى" — يُرسَل فقط عند وجود فرق إيجابي حقيقي - 'driver_earnings_extra': message.data['driver_earnings_extra'], - 'driver_earnings_currency': message.data['driver_earnings_currency'], - }); + + if (Get.currentRoute != '/OrderRequestPage') { + Log.print("🚀 FCM: Navigating to OrderRequestPage..."); + Get.toNamed('/OrderRequestPage', arguments: { + 'myListString': myListString, + 'DriverList': myList, + 'body': body, + 'is_destination_match': message.data['is_destination_match'] ?? '0', + // 🆕 "أرباحك أعلى" — يُرسَل فقط عند وجود فرق إيجابي حقيقي + 'driver_earnings_extra': message.data['driver_earnings_extra'], + 'driver_earnings_currency': message.data['driver_earnings_currency'], + }); + } else { + Log.print("⚠️ [FCM] User is already on OrderRequestPage. Skipping navigation."); + } } break; diff --git a/siro_driver/lib/main.dart b/siro_driver/lib/main.dart index 04ee5232..b390082b 100755 --- a/siro_driver/lib/main.dart +++ b/siro_driver/lib/main.dart @@ -232,13 +232,20 @@ Future backgroundMessageHandler(RemoteMessage message) async { ); bool isAppInForeground = box.read(BoxName.isAppInForeground) ?? false; + String? currentRideStatus = box.read(BoxName.rideStatus); + bool hasActiveRide = (currentRideStatus == 'Begin' || + currentRideStatus == 'Apply' || + currentRideStatus == 'Arrived'); - if (!isAppInForeground) { - await TripOverlayPlugin.showOverlay(tripData, autoCloseSeconds: 15); + if (!hasActiveRide) { + if (!isAppInForeground) { + await TripOverlayPlugin.showOverlay(tripData, autoCloseSeconds: 15); + } + // 🔴 الكتابة على القرص مباشرة بدلاً من الرام لضمان انتقالها للتطبيق 🔴 + await storage.write(key: 'pending_driver_list', value: myListString); + } else { + print("⛔ [Background FCM] Ignoring new order overlay - driver is in active ride ($currentRideStatus)"); } - - // 🔴 الكتابة على القرص مباشرة بدلاً من الرام لضمان انتقالها للتطبيق 🔴 - await storage.write(key: 'pending_driver_list', value: myListString); } } } diff --git a/siro_service/lib/constant/links.dart b/siro_service/lib/constant/links.dart index 1e06bd43..4bf13f10 100644 --- a/siro_service/lib/constant/links.dart +++ b/siro_service/lib/constant/links.dart @@ -31,7 +31,7 @@ class AppLink { case 'Egypt': return 'https://location-egypt.siromove.com/siro/ride/location'; case 'Jordan': - return 'https://location.intaleq.xyz/intaleq/ride/location'; + return 'https://jordan-siro.intaleqapp.com/loction_server/siro/ride/location'; default: return 'https://location.siromove.com/siro/ride/location'; }