This commit is contained in:
Hamza-Ayed
2024-06-01 01:54:27 +03:00
parent 02fdf8b0f1
commit 22487e138d
18 changed files with 558 additions and 166 deletions

View File

@@ -420,7 +420,7 @@ class FirebaseMessagesController extends GetxController {
// });
// }
// }
//android/app/src/main/res/raw/iphone_ringtone.wav
void sendNotificationToPassengerToken(
String title, body, token, List<String> map) async {
try {
@@ -458,6 +458,43 @@ class FirebaseMessagesController extends GetxController {
}
}
void sendNotificationToPassengerTokenCALL(
String title, body, token, List<String> map) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization': 'key=${AK.serverAPI}'
},
body: jsonEncode({
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'iphone_ringtone.wav'
},
'data': {
'passengerList': map,
},
'priority': 'high',
'to': token,
}),
);
if (response.statusCode == 200) {
// Notification sent successfully
print('Notification sent successfully');
} else {
// Handle error response
print(
'Failed to send notification. Status code: ${response.statusCode}');
}
} catch (e) {
// Handle other exceptions
print('sendNotification() error: $e');
}
}
void sendNotificationToAnyWithoutData(
String title, String body, String token) async {
try {