25-10-6/1
This commit is contained in:
@@ -47,6 +47,7 @@ import '../../views/widgets/elevated_btn.dart';
|
||||
import '../../views/widgets/error_snakbar.dart';
|
||||
import '../../views/widgets/mydialoug.dart';
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../firebase/notification_service.dart';
|
||||
import '../functions/audio_record1.dart';
|
||||
import '../functions/crud.dart';
|
||||
import '../functions/launch.dart';
|
||||
@@ -984,12 +985,12 @@ class MapPassengerController extends GetxController {
|
||||
box.write(BoxName.passengerWalletTotal, '0');
|
||||
update();
|
||||
if (box.read(BoxName.parentTripSelected) == true) {
|
||||
firebaseMessagesController.sendNotificationToPassengerToken(
|
||||
"Finish Monitor".tr,
|
||||
"Finish Monitor".tr,
|
||||
box.read(BoxName.tokenParent),
|
||||
[],
|
||||
'order1.wav',
|
||||
NotificationService.sendNotification(
|
||||
target: box.read(BoxName.tokenParent),
|
||||
title: "Finish Monitor".tr,
|
||||
body: 'Finish Monitor'.tr,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
);
|
||||
box.write(BoxName.parentTripSelected, false);
|
||||
box.remove(BoxName.tokenParent);
|
||||
@@ -1396,28 +1397,6 @@ class MapPassengerController extends GetxController {
|
||||
'distance': distance.toStringAsFixed(1),
|
||||
'duration': duration.toStringAsFixed(1),
|
||||
});
|
||||
|
||||
if (AppLink.endPoint != AppLink.IntaleqCairoServer) {
|
||||
CRUD().post(
|
||||
link: '${AppLink.endPoint}/notificationCaptain/addWaitingRide.php',
|
||||
payload: {
|
||||
'id': rideId.toString(),
|
||||
'start_location':
|
||||
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
|
||||
'end_location':
|
||||
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
|
||||
"date": DateTime.now().toString(),
|
||||
"time": DateTime.now().toString(),
|
||||
"price": totalPassenger.toStringAsFixed(2),
|
||||
'passenger_id': box.read(BoxName.passengerID).toString(),
|
||||
'status': 'waiting',
|
||||
'carType': box.read(BoxName.carType),
|
||||
'passengerRate': passengerRate.toStringAsFixed(2),
|
||||
'price_for_passenger': totalME.toStringAsFixed(2),
|
||||
'distance': distance.toStringAsFixed(1),
|
||||
'duration': duration.toStringAsFixed(0),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Future<void> confirmRideForAllDriverAvailable1() async {
|
||||
@@ -1578,7 +1557,7 @@ class MapPassengerController extends GetxController {
|
||||
// rideId,
|
||||
// driverData['token'].toString(),
|
||||
// body,
|
||||
// 'order.wav',
|
||||
// 'order',
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -1721,7 +1700,7 @@ class MapPassengerController extends GetxController {
|
||||
// rideId.toString(),
|
||||
// dataCarsLocationByPassenger['message'][i]['token'].toString(),
|
||||
// body,
|
||||
// 'order.wav');
|
||||
// 'order');
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1750,7 +1729,7 @@ class MapPassengerController extends GetxController {
|
||||
// Log.print('rideStatusDelayed == Apply: $rideStatusDelayed');
|
||||
// // todo play sound
|
||||
// Get.find<AudioRecorderController>()
|
||||
// .playSoundFromAssets('assets/start.wav');
|
||||
// .playSoundFromAssets('assets/start');
|
||||
// timer.cancel(); // Stop the current timer
|
||||
// await getUpdatedRideForDriverApply(rideId);
|
||||
// shouldFetch = false; // Stop further fetches
|
||||
@@ -2000,12 +1979,19 @@ class MapPassengerController extends GetxController {
|
||||
Future.delayed(const Duration(microseconds: 10));
|
||||
final body = constructNotificationBody(driverData);
|
||||
Log.print('body:ww $body');
|
||||
firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Order', // without tr since background not valid
|
||||
endNameAddress,
|
||||
(driverData['token'].toString()),
|
||||
body,
|
||||
'order.wav');
|
||||
// firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'Order', // without tr since background not valid
|
||||
// endNameAddress,
|
||||
// (driverData['token'].toString()),
|
||||
// body,
|
||||
// 'order');
|
||||
NotificationService.sendNotification(
|
||||
target: (driverData['token'].toString()),
|
||||
title: 'Order',
|
||||
body: endNameAddress,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
driverList: body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2049,12 +2035,19 @@ class MapPassengerController extends GetxController {
|
||||
// Log.print('body:ww ${body}');
|
||||
Log.print(
|
||||
'[DEBUG] Sending to driver: ${driverData['driver_id']}, token: ${driverData['token']}');
|
||||
firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Order', // without tr since background not valid
|
||||
endNameAddress,
|
||||
(driverData['token'].toString()),
|
||||
body,
|
||||
'order.wav');
|
||||
// firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'Order', // without tr since background not valid
|
||||
// endNameAddress,
|
||||
// (driverData['token'].toString()),
|
||||
// body,
|
||||
// 'order');
|
||||
NotificationService.sendNotification(
|
||||
target: (driverData['token'].toString()),
|
||||
title: 'Order',
|
||||
body: endNameAddress,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
driverList: body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2146,9 +2139,10 @@ class MapPassengerController extends GetxController {
|
||||
} else if (rideStatusDelayed == 'Apply' ||
|
||||
rideStatusDelayed == 'Applied') {
|
||||
isApplied = true;
|
||||
timer.cancel();
|
||||
rideAppliedFromDriver(isApplied);
|
||||
// timer.cancel();
|
||||
rideAppliedFromDriver(isApplied);
|
||||
|
||||
timer.cancel();
|
||||
// Close stream after applying
|
||||
} else if (attemptCounter >= maxAttempts ||
|
||||
rideStatusDelayed == 'waiting') {
|
||||
@@ -2188,7 +2182,7 @@ class MapPassengerController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
rideAppliedFromDriver(bool isApplied) async {
|
||||
Future<void> rideAppliedFromDriver(bool isApplied) async {
|
||||
await getUpdatedRideForDriverApply(rideId);
|
||||
NotificationController().showNotification(
|
||||
'Accepted Ride',
|
||||
@@ -2310,12 +2304,20 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
// driversToken.remove(driverToken);
|
||||
// for (var i = 1; i < driversToken.length; i++) {
|
||||
firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Order Accepted',
|
||||
'$driverName${'Accepted your order'.tr}',
|
||||
driverToken.toString(),
|
||||
[],
|
||||
'start.wav',
|
||||
// firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'Order Accepted',
|
||||
// '$driverName${'Accepted your order'.tr}',
|
||||
// driverToken.toString(),
|
||||
// [],
|
||||
// 'start',
|
||||
// );
|
||||
NotificationService.sendNotification(
|
||||
target: driverToken.toString(),
|
||||
title: 'Order Accepted',
|
||||
body: '$driverName${'Accepted your order'.tr}',
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
// driverList: body,
|
||||
);
|
||||
// }
|
||||
// }
|
||||
@@ -3054,12 +3056,20 @@ class MapPassengerController extends GetxController {
|
||||
var tokenParent = (res1['data'][0]['token']);
|
||||
Get.snackbar("The invitation was sent successfully".tr, '',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
firebaseMessagesController.sendNotificationToPassengerToken(
|
||||
"Trip Monitoring".tr,
|
||||
"Trip Monitoring".tr,
|
||||
tokenParent,
|
||||
[rideId, driverId],
|
||||
'order1.wav',
|
||||
// firebaseMessagesController.sendNotificationToPassengerToken(
|
||||
// "Trip Monitoring".tr,
|
||||
// "Trip Monitoring".tr,
|
||||
// tokenParent,
|
||||
// [rideId, driverId],
|
||||
// 'order1',
|
||||
// );
|
||||
NotificationService.sendNotification(
|
||||
target: tokenParent.toString(),
|
||||
title: "Trip Monitoring".tr,
|
||||
body: "Trip Monitoring".tr,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
driverList: [rideId, driverId],
|
||||
);
|
||||
box.write(BoxName.parentTripSelected, true);
|
||||
box.write(BoxName.tokenParent, tokenParent);
|
||||
@@ -3326,14 +3336,21 @@ class MapPassengerController extends GetxController {
|
||||
changeCancelRidePageShow();
|
||||
if (rideId != 'yet') {
|
||||
Log.print('cancelRide: 1');
|
||||
await firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Cancel Trip',
|
||||
'Trip Cancelled'.tr,
|
||||
driverToken.toString(),
|
||||
[],
|
||||
'cancel.wav',
|
||||
// await firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'Cancel Trip',
|
||||
// 'Trip Cancelled'.tr,
|
||||
// driverToken.toString(),
|
||||
// [],
|
||||
// 'cancel',
|
||||
// );
|
||||
await NotificationService.sendNotification(
|
||||
target: driverToken.toString(),
|
||||
title: 'Cancel Trip'.tr,
|
||||
body: 'Cancel Trip'.tr,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
driverList: [],
|
||||
);
|
||||
|
||||
await Future.wait([
|
||||
CRUD().post(link: AppLink.updateRides, payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
@@ -5713,37 +5730,67 @@ class MapPassengerController extends GetxController {
|
||||
timeSelected);
|
||||
// Optionally, set up local notification or send a push notification
|
||||
|
||||
await firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'OrderVIP',
|
||||
rideId.toString(),
|
||||
// await firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'OrderVIP',
|
||||
// rideId.toString(),
|
||||
// (driver['token'].toString()),
|
||||
// [
|
||||
// id,
|
||||
// rideId,
|
||||
// driver['id'],
|
||||
// passengerLocation.latitude.toString(),
|
||||
// startNameAddress.toString(),
|
||||
// passengerLocation.longitude.toString(),
|
||||
// (box.read(BoxName.name).toString().split(' ')[0]).toString(),
|
||||
// box.read(BoxName.passengerID).toString(),
|
||||
// box.read(BoxName.phone).toString(),
|
||||
// box.read(BoxName.email).toString(),
|
||||
// box.read(BoxName.passengerPhotoUrl).toString(),
|
||||
// box.read(BoxName.tokenFCM).toString(),
|
||||
// (driver['token'].toString()),
|
||||
// ],
|
||||
// 'order');
|
||||
await NotificationService.sendNotification(
|
||||
target: driver['token'].toString(),
|
||||
title: 'OrderVIP',
|
||||
body: '$rideId - VIP Trip',
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'tone1',
|
||||
driverList: [
|
||||
id,
|
||||
rideId,
|
||||
driver['id'],
|
||||
passengerLocation.latitude.toString(),
|
||||
startNameAddress.toString(),
|
||||
passengerLocation.longitude.toString(),
|
||||
(box.read(BoxName.name).toString().split(' ')[0]).toString(),
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
box.read(BoxName.phone).toString(),
|
||||
box.read(BoxName.email).toString(),
|
||||
box.read(BoxName.passengerPhotoUrl).toString(),
|
||||
box.read(BoxName.tokenFCM).toString(),
|
||||
(driver['token'].toString()),
|
||||
[
|
||||
id,
|
||||
rideId,
|
||||
driver['id'],
|
||||
passengerLocation.latitude.toString(),
|
||||
startNameAddress.toString(),
|
||||
passengerLocation.longitude.toString(),
|
||||
(box.read(BoxName.name).toString().split(' ')[0]).toString(),
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
box.read(BoxName.phone).toString(),
|
||||
box.read(BoxName.email).toString(),
|
||||
box.read(BoxName.passengerPhotoUrl).toString(),
|
||||
box.read(BoxName.tokenFCM).toString(),
|
||||
(driver['token'].toString()),
|
||||
],
|
||||
'order.wav');
|
||||
],
|
||||
);
|
||||
if (response['message'] == "Trip updated successfully") {
|
||||
mySnackbarSuccess("Trip updated successfully".tr);
|
||||
Log.print(
|
||||
'previous_driver_token: ${response['previous_driver_token']}');
|
||||
|
||||
firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Order VIP Canceld'.tr,
|
||||
'Passenger cancel order'.tr,
|
||||
response['previous_driver_token'].toString(),
|
||||
[],
|
||||
'cancel.wav',
|
||||
// firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'Order VIP Canceld'.tr,
|
||||
// 'Passenger cancel order'.tr,
|
||||
// response['previous_driver_token'].toString(),
|
||||
// [],
|
||||
// 'cancel',
|
||||
// );
|
||||
await NotificationService.sendNotification(
|
||||
target: response['previous_driver_token'].toString(),
|
||||
title: 'Order VIP Canceld'.tr,
|
||||
body: 'Passenger cancel order'.tr,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'cancel',
|
||||
driverList: [],
|
||||
);
|
||||
}
|
||||
// data = [];
|
||||
@@ -5767,7 +5814,7 @@ class MapPassengerController extends GetxController {
|
||||
// 'Passenger cancel order'.tr,
|
||||
// token,
|
||||
// [],
|
||||
// 'cancel.wav',
|
||||
// 'cancel',
|
||||
// );
|
||||
var res = await CRUD()
|
||||
.post(link: AppLink.cancelMishwari, payload: {'id': tripId});
|
||||
@@ -5778,12 +5825,20 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
sendToDriverAgain(String token) {
|
||||
firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Order VIP Canceld'.tr,
|
||||
'Passenger cancel order'.tr,
|
||||
token,
|
||||
[],
|
||||
'cancel.wav',
|
||||
// firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
// 'Order VIP Canceld'.tr,
|
||||
// 'Passenger cancel order'.tr,
|
||||
// token,
|
||||
// [],
|
||||
// 'cancel',
|
||||
// );
|
||||
NotificationService.sendNotification(
|
||||
target: token.toString(),
|
||||
title: 'Order VIP Canceld'.tr,
|
||||
body: 'Passenger cancel order'.tr,
|
||||
isTopic: false, // Important: this is a token
|
||||
tone: 'cancel',
|
||||
driverList: [],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user