Update: 2026-07-04 15:39:18
This commit is contained in:
@@ -20,6 +20,7 @@ import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
import 'constant/info.dart';
|
||||
import 'constant/box_name.dart';
|
||||
import 'controller/home/ios_live_activity_service.dart';
|
||||
import 'services/android_live_update_service.dart';
|
||||
import 'controller/local/local_controller.dart';
|
||||
import 'controller/local/translations.dart';
|
||||
import 'controller/themes/themes.dart';
|
||||
@@ -39,7 +40,7 @@ DbSql sql = DbSql.instance;
|
||||
Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
Log.print("Handling a background message: ${message.messageId}");
|
||||
|
||||
|
||||
if (message.data.isNotEmpty) {
|
||||
try {
|
||||
await GetStorage.init();
|
||||
@@ -51,10 +52,12 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
||||
if (!serviceEnabled) return;
|
||||
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied || permission == LocationPermission.deniedForever) return;
|
||||
if (permission == LocationPermission.denied ||
|
||||
permission == LocationPermission.deniedForever) return;
|
||||
|
||||
final position = await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.high);
|
||||
|
||||
final position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
|
||||
final url = Uri.parse('${AppLink.server}/api/location/sync_location.php');
|
||||
await http.post(url, body: {
|
||||
'passenger_id': passengerId.toString(),
|
||||
@@ -62,9 +65,10 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
||||
'lng': position.longitude.toString(),
|
||||
'source': 'silent_push',
|
||||
});
|
||||
|
||||
|
||||
// Update geofences on device silently
|
||||
await SiroGeofencingService.syncZonesWithServer(position.latitude, position.longitude);
|
||||
await SiroGeofencingService.syncZonesWithServer(
|
||||
position.latitude, position.longitude);
|
||||
} catch (e) {
|
||||
Log.print("Silent push location update failed: $e");
|
||||
}
|
||||
@@ -89,6 +93,9 @@ void main() {
|
||||
// ✅ التعديل هنا: تهيئة خدمة الـ Live Activity للآيفون
|
||||
IosLiveActivityService.init();
|
||||
|
||||
// ✅ تهيئة خدمة Android Live Update (Progress Style)
|
||||
await AndroidLiveUpdateService.init();
|
||||
|
||||
// Initialize Geofencing Service
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await SiroGeofencingService.initAndStart();
|
||||
|
||||
Reference in New Issue
Block a user