6/22/1
This commit is contained in:
@@ -32,8 +32,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
// Get the current notification settings
|
||||
NotificationSettings? notificationSettings =
|
||||
await FirebaseMessaging.instance.getNotificationSettings();
|
||||
print(
|
||||
'Notification authorization status: ${notificationSettings.authorizationStatus}');
|
||||
'Notification authorization status: ${notificationSettings.authorizationStatus}';
|
||||
|
||||
// Call the update function if needed
|
||||
update();
|
||||
@@ -57,7 +56,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
provisional: false,
|
||||
sound: true,
|
||||
);
|
||||
print('User granted permission: ${settings.authorizationStatus}');
|
||||
messaging.setForegroundNotificationPresentationOptions(
|
||||
alert: true, badge: true, sound: true);
|
||||
}
|
||||
@@ -66,8 +64,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
box.write(BoxName.tokenDriver, token);
|
||||
|
||||
print(token);
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
@@ -82,14 +78,12 @@ class FirebaseMessagesController extends GetxController {
|
||||
FirebaseMessaging.onBackgroundMessage((RemoteMessage message) async {
|
||||
// Handle background message
|
||||
if (message.data.isNotEmpty && message.notification != null) {
|
||||
print(message.notification?.title);
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||
if (message.data.isNotEmpty && message.notification != null) {
|
||||
print(message.notification?.title);
|
||||
fireBaseTitles(message);
|
||||
}
|
||||
});
|
||||
@@ -109,7 +103,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
// This is for location using and uploading status
|
||||
Get.put(HomeCaptainController()).changeRideId();
|
||||
update();
|
||||
// print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
@@ -153,9 +146,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
// token: driverList[0].toString(),
|
||||
// remoteID: driverList[2].toString(),
|
||||
// ));
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} catch (e) {}
|
||||
} else if (message.notification!.title! == 'Call Income from Passenger') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
@@ -173,9 +164,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
// token: driverList[0].toString(),
|
||||
// remoteID: driverList[2].toString(),
|
||||
));
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} catch (e) {}
|
||||
} else if (message.notification!.title! == 'Call End') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
@@ -189,9 +178,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
Get.off(const CallPage());
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} catch (e) {}
|
||||
} else if (message.notification!.title! == 'Order Applied') {
|
||||
Get.snackbar(
|
||||
"The order has been accepted by another driver."
|
||||
@@ -209,7 +196,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
// var myPoints = jsonDecode(points) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
update();
|
||||
// print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderSpeedRequest(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
@@ -364,7 +350,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
// Save the list of tokens back to the box.
|
||||
// box.write(BoxName.tokens, tokens);
|
||||
tokens = box.read(BoxName.tokens);
|
||||
// print(tokens);
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
http
|
||||
.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
@@ -387,9 +372,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
'to': tokens[i],
|
||||
}))
|
||||
.whenComplete(() {})
|
||||
.catchError((e) {
|
||||
print('sendNotification() error: $e');
|
||||
});
|
||||
.catchError((e) {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +399,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
// }))
|
||||
// .whenComplete(() {})
|
||||
// .catchError((e) {
|
||||
// print('sendNotification() error: $e');
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
@@ -446,15 +428,12 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
print('Notification sent successfully');
|
||||
} else {
|
||||
// Handle error response
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
'Failed to send notification. Status code: ${response.statusCode}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,15 +462,12 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
print('Notification sent successfully');
|
||||
} else {
|
||||
// Handle error response
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
'Failed to send notification. Status code: ${response.statusCode}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,15 +498,12 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
print('Notification sent successfully');
|
||||
} else {
|
||||
// Handle error response
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
'Failed to send notification. Status code: ${response.statusCode}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,15 +533,12 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
print('Notification sent successfully');
|
||||
} else {
|
||||
// Handle error response
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
'Failed to send notification. Status code: ${response.statusCode}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,15 +569,12 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Notification sent successfully
|
||||
print('Notification sent successfully');
|
||||
} else {
|
||||
// Handle error response
|
||||
print(
|
||||
'Failed to send notification. Status code: ${response.statusCode}');
|
||||
'Failed to send notification. Status code: ${response.statusCode}';
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other exceptions
|
||||
print('sendNotification() error: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user