Update: 2026-07-23 22:14:10
This commit is contained in:
@@ -23,6 +23,7 @@ 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/firebase/local_notification.dart';
|
||||
import 'controller/themes/themes.dart';
|
||||
import 'firebase_options.dart';
|
||||
import 'models/db_sql.dart';
|
||||
@@ -72,6 +73,48 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
||||
} catch (e) {
|
||||
Log.print("Silent push location update failed: $e");
|
||||
}
|
||||
|
||||
// 🆕 عرض الإشعارات المترجمة في الخلفية
|
||||
try {
|
||||
final category = message.data['category'] ?? '';
|
||||
if (category == 'Accepted Ride' ||
|
||||
category == 'Arrive Ride' ||
|
||||
category == 'Trip is Begin' ||
|
||||
category == 'Driver Finish Trip') {
|
||||
final storage = GetStorage();
|
||||
final lang = storage.read(BoxName.lang) ?? 'ar';
|
||||
String titleKey = '';
|
||||
String bodyKey = '';
|
||||
|
||||
if (category == 'Accepted Ride') {
|
||||
titleKey = 'Ride Accepted ✅';
|
||||
bodyKey = 'The captain is on their way to you now.';
|
||||
} else if (category == 'Arrive Ride') {
|
||||
titleKey = 'Driver is outside 🚖';
|
||||
bodyKey = 'The captain has arrived at your location.';
|
||||
} else if (category == 'Trip is Begin') {
|
||||
titleKey = 'Trip Begun 🚀';
|
||||
bodyKey = 'Have a safe and comfortable trip.';
|
||||
} else if (category == 'Driver Finish Trip') {
|
||||
titleKey = 'Trip Finished 🏁';
|
||||
bodyKey = 'Please pay and rate the driver.';
|
||||
}
|
||||
|
||||
// ترجمة باستخدام ملفات الترجمة حتى في الخلفية
|
||||
String title = titleKey;
|
||||
String body = bodyKey;
|
||||
|
||||
if (lang.toString().startsWith('ar')) {
|
||||
title = MyTranslation().keys['ar']?[titleKey] ?? titleKey;
|
||||
body = MyTranslation().keys['ar']?[bodyKey] ?? bodyKey;
|
||||
}
|
||||
|
||||
// عرض الإشعار المحلي عبر الكلاس المخصص
|
||||
await NotificationController.showBackgroundNotification(title, body, 'ding');
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print("Background local notification failed: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +142,8 @@ void main() {
|
||||
// Initialize Geofencing Service only if permission is already granted to avoid auto-prompt
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission != LocationPermission.denied && permission != LocationPermission.deniedForever) {
|
||||
if (permission != LocationPermission.denied &&
|
||||
permission != LocationPermission.deniedForever) {
|
||||
await SiroGeofencingService.initAndStart();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user