This commit is contained in:
Hamza-Ayed
2025-07-01 18:30:08 +03:00
parent cf8966ea29
commit 322e4b9788
11 changed files with 1445 additions and 74 deletions

View File

@@ -121,13 +121,13 @@ class FirebaseMessagesController extends GetxController {
});
}
void fireBaseTitles(RemoteMessage message) {
Future<void> fireBaseTitles(RemoteMessage message) async {
if (message.notification!.title! == 'Order'.tr) {
if (Platform.isAndroid) {
notificationController.showNotification(
'Order', message.notification!.body!, 'Order');
}
} else if (message.notification!.title! == 'Accepted Ride'.tr) {
} else if (message.notification!.title! == 'Accepted Ride') {
if (Platform.isAndroid) {
notificationController.showNotification(
'Accepted Ride'.tr, 'Driver Accepted the Ride for You'.tr, 'ding');
@@ -136,13 +136,16 @@ class FirebaseMessagesController extends GetxController {
var myList = jsonDecode(passengerList) as List<dynamic>;
Log.print('myList: ${myList}');
driverID = myList[0].toString();
// Get.find<MapPassengerController>().driverToken = myList[2].toString();
// Log.print('driverToken: ${myList[2]}');
Get.find<MapPassengerController>().statusRide = 'Apply';
Get.find<MapPassengerController>().isSearchingWindow = false;
Get.find<MapPassengerController>().update();
Get.find<MapPassengerController>().rideAppliedFromDriver(true);
final controller = Get.find<MapPassengerController>();
controller.driverId = myList[0].toString();
// assume rideId lives at index 2 in your list:
controller.rideId = myList[3].toString();
controller
..statusRide = 'Apply'
..isSearchingWindow = false
..update();
await controller.rideAppliedFromDriver(true);
// driverAppliedTripSnakBar();
} else if (message.notification!.title! == 'Promo'.tr) {
@@ -557,7 +560,9 @@ class FirebaseMessagesController extends GetxController {
// });
// }
// }
late String serviceAccountKeyJson;
@override
Future<void> onInit() async {
super.onInit();
@@ -565,7 +570,8 @@ class FirebaseMessagesController extends GetxController {
var encryptedKey = await storage.read(key: 'FCM_PRIVATE_KEY');
// Log.print('encryptedKey: ${encryptedKey}');
if (encryptedKey != null) {
serviceAccountKeyJson = (encryptedKey);
serviceAccountKeyJson =
EncryptionHelper.instance.decryptData(encryptedKey);
// Log.print('serviceAccountKeyJson: ${serviceAccountKeyJson}');
} else {
print('🔴 Error: FCM_PRIVATE_KEY not found in Secure Storage');
@@ -647,11 +653,12 @@ class FirebaseMessagesController extends GetxController {
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Log.print('accessTokenManager: ${accessTokenManager}');
// Log.print(
// 'accessTokenManager: ${accessTokenManager.serviceAccountJsonKey}');
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
Log.print('accessToken: ${accessToken}');
// Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(