10/3/1
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/controller/functions/launch.dart';
|
||||
import 'package:ride/controller/home/captin/map_dirction.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';
|
||||
@@ -18,19 +19,20 @@ import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/orderCaptin/order_request_page.dart';
|
||||
|
||||
class FirebasMessagesController extends GetxController {
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
final fcmToken = FirebaseMessaging.instance;
|
||||
|
||||
List<String> tokens = [];
|
||||
List dataTokens = [];
|
||||
late String driverID;
|
||||
late String driverToken;
|
||||
NotificationSettings? notificationSettings;
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
// getNotificationSettings();
|
||||
getToken();
|
||||
await getTokens();
|
||||
// getToken();
|
||||
// await getTokens();
|
||||
}
|
||||
|
||||
Future<void> getNotificationSettings() async {
|
||||
@@ -106,6 +108,9 @@ class FirebasMessagesController extends GetxController {
|
||||
print(myListString);
|
||||
print('9999999999999myListString999999999999999');
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
update();
|
||||
print('driverToken==============' + driverToken.toString());
|
||||
Get.to(() => OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
@@ -117,6 +122,7 @@ class FirebasMessagesController extends GetxController {
|
||||
print('9999999999999my Apply Ride 999999999999999');
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
driverID = myList[2].toString();
|
||||
|
||||
Get.snackbar(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
'message',
|
||||
@@ -178,12 +184,15 @@ class FirebasMessagesController extends GetxController {
|
||||
);
|
||||
} else if (message.notification!.title!.contains('Promo')) {
|
||||
Get.to(const PromosPassengerPage());
|
||||
} else if (message.notification!.title == ('Ride Begin')) {
|
||||
Get.snackbar(
|
||||
'Trip Begin'.tr,
|
||||
'by Passenger'.tr,
|
||||
backgroundColor: AppColor.yellowColor,
|
||||
} else if (message.notification!.title!.contains('BeginTrip')) {
|
||||
// MapDirection mapDirection = Get.find<MapDirection>();
|
||||
// mapDirection.clearPolyline();
|
||||
print('jjjjjjjjjjjjjjjjjjjjjjjjjjj');
|
||||
Get.defaultDialog(
|
||||
title: 'The Ride is Begin'.tr,
|
||||
backgroundColor: AppColor.greenColor,
|
||||
);
|
||||
MapDirection().clearPolyline();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -470,27 +479,39 @@ class FirebasMessagesController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToDriverId(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'
|
||||
},
|
||||
'data': {},
|
||||
'priority': 'high',
|
||||
'to': token,
|
||||
}))
|
||||
.whenComplete(() {})
|
||||
.catchError((e) {
|
||||
void sendNotificationToDriverId(
|
||||
String title, String body, String token) 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': {},
|
||||
'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');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void sendNotificationToDriverMAP(
|
||||
|
||||
Reference in New Issue
Block a user