import 'dart:convert'; import 'package:http/http.dart' as http; import '../../print.dart'; class NotificationService { // تأكد من أن هذا هو الرابط الصحيح لملف الإرسال static const String _serverUrl = 'https://syria.intaleq.xyz/intaleq/fcm/send_fcm.php'; static Future sendNotification({ required String target, required String title, required String body, required String? category, // <-- [الإضافة الأولى] String? tone, List? driverList, bool isTopic = false, }) async { try { final Map payload = { 'target': target, 'title': title, 'body': body, 'isTopic': isTopic, }; if (category != null) { payload['category'] = category; // <-- [الإضافة الثانية] } if (tone != null) { payload['tone'] = tone; } if (driverList != null) { // [مهم] تطبيق السائق يرسل passengerList payload['passengerList'] = jsonEncode(driverList); } final response = await http.post( Uri.parse(_serverUrl), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: jsonEncode(payload), ); if (response.statusCode == 200) { print('✅ Notification sent successfully.'); } else { print( '❌ Failed to send notification. Status code: ${response.statusCode}'); } } catch (e) { print('❌ An error occurred while sending notification: $e'); } } }