3/21/1
This commit is contained in:
@@ -16,6 +16,7 @@ import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
|
||||
import '../../views/home/map_page_passenger.dart';
|
||||
import '../../views/home/map_widget.dart/call_passenger_page.dart';
|
||||
import '../../views/home/profile/promos_passenger_page.dart';
|
||||
@@ -105,10 +106,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
// if (message.notification != null && message.data.isNotEmpty) {
|
||||
// fireBaseTitles(message);
|
||||
// }
|
||||
|
||||
// If the app is in the background or terminated, show a system tray message
|
||||
RemoteNotification? notification = message.notification;
|
||||
AndroidNotification? android = notification?.android;
|
||||
@@ -117,13 +114,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
});
|
||||
|
||||
// FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||
// // print(
|
||||
// // 'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
||||
// RemoteNotification? notification = message.notification;
|
||||
// fireBaseTitles(message);
|
||||
// });
|
||||
}
|
||||
|
||||
void fireBaseTitles(RemoteMessage message) {
|
||||
@@ -132,14 +122,17 @@ class FirebaseMessagesController extends GetxController {
|
||||
NotificationController().showNotification('Order', '', 'order');
|
||||
}
|
||||
var myListString = message.data['DriverList'];
|
||||
// var points = message.data['PolylineJson'];
|
||||
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
// var myPoints = jsonDecode(points) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
update();
|
||||
// print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
// 'PolylineJson': myPoints,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
} else if (message.notification!.title! == 'Apply Ride') {
|
||||
@@ -228,6 +221,28 @@ class FirebaseMessagesController extends GetxController {
|
||||
'order');
|
||||
Get.find<MapPassengerController>().restCounter();
|
||||
Get.offAll(const MapPagePassenger());
|
||||
} else if (message.notification!.title! == 'Order Applied') {
|
||||
Get.snackbar(
|
||||
"The order has been accepted by another driver.", // Corrected grammar
|
||||
"Be more mindful next time to avoid dropping orders.", // Improved sentence structure
|
||||
backgroundColor: AppColor.yellowColor,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} else if (message.notification!.title! == 'OrderSpeed') {
|
||||
var myListString = message.data['DriverList'];
|
||||
// var points = message.data['PolylineJson'];
|
||||
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
// var myPoints = jsonDecode(points) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
update();
|
||||
// print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderSpeedRequest(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
// 'PolylineJson': myPoints,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,6 +532,45 @@ class FirebaseMessagesController extends GetxController {
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToDriverMapPolyline(String title, String body,
|
||||
String token, List<String> data, String polylineJson) 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': 'tone2.wav',
|
||||
'sound': 'order.wav'
|
||||
},
|
||||
'data': {
|
||||
'DriverList': data,
|
||||
'PolylineJson': polylineJson,
|
||||
},
|
||||
'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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DriverTipWidget extends StatelessWidget {
|
||||
|
||||
Reference in New Issue
Block a user