This commit is contained in:
Hamza-Ayed
2024-06-30 12:35:55 +03:00
parent 6fb79baab4
commit d423cc0831
27 changed files with 517 additions and 452 deletions

View File

@@ -90,9 +90,9 @@ class FirebaseMessagesController extends GetxController {
}
void fireBaseTitles(RemoteMessage message) {
if (message.notification!.title! == 'Order') {
if (message.notification!.title! == 'Order'.tr) {
if (Platform.isAndroid) {
NotificationController().showNotification('Order', '', 'order');
NotificationController().showNotification('Order'.tr, '', 'order');
}
var myListString = message.data['DriverList'];
// var points = message.data['PolylineJson'];
@@ -109,27 +109,27 @@ class FirebaseMessagesController extends GetxController {
// 'PolylineJson': myPoints,
'body': message.notification!.body
});
} else if (message.notification!.title == 'Cancel Trip') {
} else if (message.notification!.title == 'Cancel Trip'.tr) {
NotificationController().showNotification(
'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel');
cancelTripDialog();
} else if (message.notification!.title! == 'token change') {
} else if (message.notification!.title! == 'token change'.tr) {
NotificationController()
.showNotification('token change', 'token change', 'cancel');
.showNotification('token change'.tr, 'token change', 'cancel');
GoogleSignInHelper.signOut();
} else if (message.notification!.title! == 'message From passenger') {
} else if (message.notification!.title! == 'message From passenger'.tr) {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
passengerDialog(message.notification!.body!);
update();
} else if (message.notification!.title! == 'Hi ,I will go now') {
} else if (message.notification!.title! == 'Hi ,I will go now'.tr) {
// Get.snackbar('Hi ,I will go now', '',
// backgroundColor: AppColor.greenColor);
NotificationController().showNotification(
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2');
update();
} else if (message.notification!.title! == 'Call Income') {
} else if (message.notification!.title! == 'Call Income'.tr) {
try {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
@@ -147,7 +147,8 @@ class FirebaseMessagesController extends GetxController {
// remoteID: driverList[2].toString(),
// ));
} catch (e) {}
} else if (message.notification!.title! == 'Call Income from Passenger') {
} else if (message.notification!.title! ==
'Call Income from Passenger'.tr) {
try {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
@@ -165,7 +166,7 @@ class FirebaseMessagesController extends GetxController {
// remoteID: driverList[2].toString(),
));
} catch (e) {}
} else if (message.notification!.title! == 'Call End') {
} else if (message.notification!.title! == 'Call End'.tr) {
try {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
@@ -179,7 +180,7 @@ class FirebaseMessagesController extends GetxController {
// Assuming GetMaterialApp is initialized and context is valid for navigation
Get.off(const CallPage());
} catch (e) {}
} else if (message.notification!.title! == 'Order Applied') {
} else if (message.notification!.title! == 'Order Applied'.tr) {
Get.snackbar(
"The order has been accepted by another driver."
.tr, // Corrected grammar
@@ -202,7 +203,7 @@ class FirebaseMessagesController extends GetxController {
// 'PolylineJson': myPoints,
'body': message.notification!.body
});
} else if (message.notification!.title! == 'Order Applied') {
} else if (message.notification!.title! == 'Order Applied'.tr) {
NotificationController().showNotification(
'The order Accepted by another Driver'.tr,
'We regret to inform you that another driver has accepted this order.'
@@ -361,7 +362,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'start.wav'
'sound': 'ding.wav'
},
'priority': 'high',
'data': <String, dynamic>{
@@ -404,7 +405,7 @@ class FirebaseMessagesController extends GetxController {
// }
//android/app/src/main/res/raw/iphone_ringtone.wav
void sendNotificationToPassengerToken(
String title, body, token, List<String> map) async {
String title, body, token, List<String> map, String tone) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -416,7 +417,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'tone2.wav'
'sound': tone
},
'data': {
'passengerList': map,
@@ -472,7 +473,7 @@ class FirebaseMessagesController extends GetxController {
}
void sendNotificationToAnyWithoutData(
String title, String body, String token) async {
String title, String body, String token, String tone) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -484,7 +485,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'promo.wav'
'sound': tone
},
'data': <String, dynamic>{
'click_action': 'FLUTTER_NOTIFICATION_CLICK',
@@ -507,8 +508,8 @@ class FirebaseMessagesController extends GetxController {
}
}
void sendNotificationToDriverMAP(
String title, String body, String token, List<String> data) async {
void sendNotificationToDriverMAP(String title, String body, String token,
List<String> data, String tone) async {
try {
final response = await http.post(
Uri.parse('https://fcm.googleapis.com/fcm/send'),
@@ -521,7 +522,7 @@ class FirebaseMessagesController extends GetxController {
'title': title,
'body': body,
// 'sound': 'tone2.wav',
'sound': 'order.wav'
'sound': tone
},
'data': {
'DriverList': data,