9/11/1
This commit is contained in:
@@ -9,6 +9,7 @@ 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/controller/home/map_page_controller.dart';
|
||||
import 'package:ride/views/home/profile/promos_passenger_page.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
@@ -101,11 +102,13 @@ class FirebasMessagesController extends GetxController {
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
if (message.data.isNotEmpty) {
|
||||
if (message.notification!.title!.contains('Order')) {
|
||||
var myListString = message.data['myList'];
|
||||
var myListString = message.data['DriverList'];
|
||||
print(myListString);
|
||||
print('9999999999999myListString999999999999999');
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
Get.to(() => const OrderRequestPage(), arguments: {
|
||||
Get.to(() => OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'myList': myList,
|
||||
'DriverList': myList,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
// Get.defaultDialog(
|
||||
@@ -199,6 +202,25 @@ class FirebasMessagesController extends GetxController {
|
||||
// )
|
||||
// ],
|
||||
// ));
|
||||
} else if (message.notification!.title!.contains('Apply Ride')) {
|
||||
// MapController().rideConfirm = true;
|
||||
var passengerList = message.data['passengerList'];
|
||||
print(passengerList);
|
||||
print('9999999999999my Apply Ride 999999999999999');
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: message.notification!.title.toString(),
|
||||
content: Row(
|
||||
children: [Text(myList[1].toString())],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok',
|
||||
onPressed: () {
|
||||
// MapController().rideConfirm = true;
|
||||
},
|
||||
));
|
||||
} else if (message.notification!.title!.contains('Promo')) {
|
||||
Get.to(const PromosPassengerPage());
|
||||
}
|
||||
@@ -381,35 +403,58 @@ class FirebasMessagesController extends GetxController {
|
||||
// }
|
||||
// }
|
||||
|
||||
// void sendNotificationDriverId(String title, body, token) async {
|
||||
// http
|
||||
// .post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
// },
|
||||
// body: jsonEncode({
|
||||
// 'notification': <String, dynamic>{
|
||||
// 'title': title,
|
||||
// 'body': body,
|
||||
// 'sound': 'true'
|
||||
// },
|
||||
// 'priority': 'high',
|
||||
// 'data': <String, dynamic>{
|
||||
// 'click_action': 'FLUTTER_NOTIFICATION_CLICK',
|
||||
// 'id': '1',
|
||||
// 'status': 'done'
|
||||
// },
|
||||
// 'to': token,
|
||||
// }))
|
||||
// .whenComplete(() {})
|
||||
// .catchError((e) {
|
||||
// print('sendNotification() error: $e');
|
||||
// });
|
||||
// }
|
||||
void sendNotificanToPassengerToken(
|
||||
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=${AppCredintials.serverAPI}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
'title': title,
|
||||
'body': body,
|
||||
'sound': 'true'
|
||||
},
|
||||
'data': {
|
||||
'passengerList': map,
|
||||
},
|
||||
'priority': 'high',
|
||||
'to': token,
|
||||
}),
|
||||
);
|
||||
|
||||
void sendNotificationDriverId(String title, body, strin1, strin2, strin3,
|
||||
strin4, strin5, strin6, string7, string8, token) async {
|
||||
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 sendNotificationToDriverId(
|
||||
String title,
|
||||
body,
|
||||
strin1,
|
||||
strin2,
|
||||
strin3,
|
||||
strin4,
|
||||
strin5,
|
||||
strin6,
|
||||
string7,
|
||||
string8,
|
||||
passengerName,
|
||||
passengertoken,
|
||||
passengerPhone,
|
||||
token) async {
|
||||
http
|
||||
.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
@@ -431,7 +476,10 @@ class FirebasMessagesController extends GetxController {
|
||||
strin5,
|
||||
strin6,
|
||||
string7,
|
||||
string8
|
||||
string8,
|
||||
passengerName,
|
||||
passengertoken,
|
||||
passengerPhone
|
||||
]),
|
||||
},
|
||||
'priority': 'high',
|
||||
@@ -442,4 +490,41 @@ class FirebasMessagesController extends GetxController {
|
||||
print('sendNotification() error: $e');
|
||||
});
|
||||
}
|
||||
|
||||
void sendNotificationToDriverMAP(
|
||||
String title, String body, String token, List<String> data) async {
|
||||
try {
|
||||
final response = await http.post(
|
||||
Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
'title': title,
|
||||
'body': body,
|
||||
'sound': 'true'
|
||||
},
|
||||
'data': {
|
||||
'DriverList': data,
|
||||
},
|
||||
'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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user