9/8/1-captin
This commit is contained in:
@@ -9,12 +9,14 @@ import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/controller/functions/launch.dart';
|
||||
import 'package:ride/controller/functions/toast.dart';
|
||||
import 'package:ride/views/home/profile/promos_passenger_page.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/credential.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/orderCaptin/order_request_page.dart';
|
||||
|
||||
class FirebasMessagesController extends GetxController {
|
||||
final fcmToken = FirebaseMessaging.instance;
|
||||
@@ -92,15 +94,127 @@ class FirebasMessagesController extends GetxController {
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
box.write(BoxName.tokenFCM, token);
|
||||
box.write(BoxName.tokenDriver, token);
|
||||
print(token);
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
if (message.data.isNotEmpty) {
|
||||
if (message.notification!.title!.contains('Order')) {
|
||||
var myListString = message.data['myList'];
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.to(() => const OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'myList': myList,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
// Get.defaultDialog(
|
||||
// barrierDismissible: false,
|
||||
// title: message.notification!.title.toString(),
|
||||
// content: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// // Text(message.notification!.body.toString()),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: TextButton.icon(
|
||||
// onPressed: () {
|
||||
// String mapUrl =
|
||||
// 'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
|
||||
// print(mapUrl);
|
||||
// launchUrl1(mapUrl);
|
||||
// },
|
||||
// icon: const Icon(Icons.map),
|
||||
// label: Text('Rouats of Trip'.tr)),
|
||||
// ),
|
||||
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// 'Tatal From Passenger is '.tr +
|
||||
// double.parse(myList[2]).toStringAsFixed(2),
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// 'Tatal For You is '.tr +
|
||||
// double.parse(myList[3]).toStringAsFixed(2),
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// 'Distance is '.tr + myList[5].toString() + ' KM'.tr,
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// 'Duration of Trip is '.tr +
|
||||
// myList[4].toString() +
|
||||
// ' Minutes'.tr,
|
||||
// style: AppStyle.title,
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// MyElevatedButton(
|
||||
// title: 'Apply Order'.tr,
|
||||
// onPressed: () async {
|
||||
// await CRUD().postFromDialogue(
|
||||
// link: AppLink.addDriverOrder,
|
||||
// payload: {
|
||||
// 'driver_id': myList[6].toString(),
|
||||
// // box.read(BoxName.driverID).toString(),
|
||||
// 'order_id':
|
||||
// message.notification!.body.toString(),
|
||||
// 'status': 'Apply'
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// MyElevatedButton(
|
||||
// title: 'Refuse Order'.tr,
|
||||
// onPressed: () async {
|
||||
// await CRUD().postFromDialogue(
|
||||
// link: AppLink.addDriverOrder,
|
||||
// payload: {
|
||||
// 'driver_id': myList[6].toString(),
|
||||
// // box.read(BoxName.driverID).toString(),
|
||||
// 'order_id':
|
||||
// message.notification!.body.toString(),
|
||||
// 'status': 'Refused'
|
||||
// });
|
||||
// },
|
||||
// kolor: AppColor.redColor,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ));
|
||||
} else if (message.notification!.title!.contains('Promo')) {
|
||||
Get.to(const PromosPassengerPage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||
print(
|
||||
'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
||||
RemoteNotification? notification = message.notification;
|
||||
if (message.data.isNotEmpty) {
|
||||
if (message.notification!.title!.contains('Order')) {
|
||||
var myListString = message.data['myList'];
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: true,
|
||||
title: message.notification!.title.toString(),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -111,7 +225,7 @@ class FirebasMessagesController extends GetxController {
|
||||
child: TextButton.icon(
|
||||
onPressed: () {
|
||||
String mapUrl =
|
||||
'https://www.google.com/maps/dir/${myList[0]}/${myList[0]}/';
|
||||
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
|
||||
print(mapUrl);
|
||||
launchUrl1(mapUrl);
|
||||
},
|
||||
@@ -191,19 +305,7 @@ class FirebasMessagesController extends GetxController {
|
||||
],
|
||||
));
|
||||
} else if (message.notification!.title!.contains('Promo')) {
|
||||
// Get.to(page)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||
print(
|
||||
'onMessageOpenedApp: ${message.notification!.title} ${message.notification!.body}');
|
||||
RemoteNotification? notification = message.notification;
|
||||
if (notification != null) {
|
||||
print('onMessageOpenedApp: ${notification.title} ${notification.body}');
|
||||
if (message.notification!.title!.contains('SEFER')) {
|
||||
Get.snackbar('SEFER', 'message', backgroundColor: AppColor.redColor);
|
||||
Get.to(const PromosPassengerPage());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -306,8 +408,8 @@ class FirebasMessagesController extends GetxController {
|
||||
// });
|
||||
// }
|
||||
|
||||
void sendNotificationDriverId(String title, body, Strin1, Strin2, Strin3,
|
||||
Strin4, Strin5, Strin6, String7, token) async {
|
||||
void sendNotificationDriverId(String title, body, strin1, strin2, strin3,
|
||||
strin4, strin5, strin6, string7, string8, token) async {
|
||||
http
|
||||
.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
@@ -321,8 +423,16 @@ class FirebasMessagesController extends GetxController {
|
||||
'sound': 'true'
|
||||
},
|
||||
'data': {
|
||||
'myList': jsonEncode(
|
||||
[Strin1, Strin2, Strin3, Strin4, Strin5, Strin6, String7]),
|
||||
'myList': jsonEncode([
|
||||
strin1,
|
||||
strin2,
|
||||
strin3,
|
||||
strin4,
|
||||
strin5,
|
||||
strin6,
|
||||
string7,
|
||||
string8
|
||||
]),
|
||||
},
|
||||
'priority': 'high',
|
||||
'to': token,
|
||||
|
||||
Reference in New Issue
Block a user