25-10-11/1

This commit is contained in:
Hamza-Ayed
2025-11-06 12:29:17 +03:00
parent 14484fcd8f
commit a69e4c6912
46 changed files with 14145 additions and 13529 deletions

View File

@@ -1,8 +1,10 @@
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../../print.dart';
class NotificationService {
// استبدل هذا الرابط بالرابط الصحيح لملف PHP على السيرفر الخاص بك
// تأكد من أن هذا هو الرابط الصحيح لملف الإرسال
static const String _serverUrl =
'https://syria.intaleq.xyz/intaleq/fcm/send_fcm.php';
@@ -10,8 +12,9 @@ class NotificationService {
required String target,
required String title,
required String body,
required String? category, // <-- [الإضافة الأولى]
String? tone,
List<String>? driverList, // <-- [تعديل 1] : إضافة المتغير الجديد
List<String>? driverList,
bool isTopic = false,
}) async {
try {
@@ -22,14 +25,17 @@ class NotificationService {
'isTopic': isTopic,
};
// نضيف النغمة فقط إذا لم تكن فارغة
if (category != null) {
payload['category'] = category; // <-- [الإضافة الثانية]
}
if (tone != null) {
payload['tone'] = tone;
}
// <-- [تعديل 2] : نضيف قائمة البيانات بعد تشفيرها إلى JSON
if (driverList != null) {
payload['driverList'] = jsonEncode(driverList);
// [مهم] تطبيق السائق يرسل passengerList
payload['passengerList'] = jsonEncode(driverList);
}
final response = await http.post(
@@ -41,15 +47,13 @@ class NotificationService {
);
if (response.statusCode == 200) {
print('✅ Notification sent successfully.');
print('Server Response: ${response.body}');
Log.print('✅ Notification sent successfully.');
} else {
print(
Log.print(
'❌ Failed to send notification. Status code: ${response.statusCode}');
print('Server Error: ${response.body}');
}
} catch (e) {
print('❌ An error occurred while sending notification: $e');
Log.print('❌ An error occurred while sending notification: $e');
}
}
}