This commit is contained in:
Hamza-Ayed
2024-10-03 22:25:44 +03:00
parent 79b14ab9cc
commit 8889780a6f
24 changed files with 853 additions and 734 deletions

View File

@@ -115,7 +115,7 @@ class FirebaseMessagesController extends GetxController {
Future<void> fireBaseTitles(RemoteMessage message) async {
if (message.notification!.title! == 'Order'.tr) {
if (Platform.isAndroid) {
NotificationController1().showNotification('Order'.tr, '', 'order', '');
NotificationController().showNotification('Order'.tr, '', 'order', '');
}
// await FirebaseMessagesController().showOverlayNotification(message);
var myListString = message.data['DriverList'];
@@ -156,6 +156,8 @@ class FirebaseMessagesController extends GetxController {
});
// Get.to(const VipOrderPage());
} else if (message.notification!.title! == 'message From passenger'.tr) {
passengerDialog(message.notification!.body!);
} else if (message.notification!.title == 'Cancel') {
cancelTripDialog1();
} else if (message.notification!.title! == 'token change') {
@@ -163,15 +165,6 @@ class FirebaseMessagesController extends GetxController {
// .showNotification('token change'.tr, 'token change', 'cancel');
// GoogleSignInHelper.signOut();
GoogleSignInHelper.signOut();
} else if (message.notification!.title! == 'message From passenger') {
// print('sdfd');
// if (Platform.isAndroid) {
// NotificationController1()
// .showNotification('message From passenger'.tr, ''.tr, 'tone2', '');
// }
passengerDialog(message.notification!.body!);
update();
} else if (message.notification!.title! == 'face detect') {
if (Platform.isAndroid) {
NotificationController1()

View File

@@ -15,7 +15,7 @@ import '../home/captin/home_captain_controller.dart';
class NotificationController extends GetxController {
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
// Initializes the local notifications plugin
Future<void> initNotifications() async {
const AndroidInitializationSettings android =
AndroidInitializationSettings('@mipmap/launcher_icon');
@@ -26,14 +26,13 @@ class NotificationController extends GetxController {
await _flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveNotificationResponse: onDidReceiveNotificationResponse,
onDidReceiveBackgroundNotificationResponse:
onDidReceiveBackgroundNotificationResponse,
onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
);
// Create a notification channel
const AndroidNotificationChannel channel = AndroidNotificationChannel(
'your channel id',
'your channel name',
'high_importance_channel', // Use the same ID as in strings.xml
'High Importance Notifications',
description: 'This channel is used for important notifications.',
importance: Importance.high,
);
@@ -56,7 +55,8 @@ class NotificationController extends GetxController {
);
AndroidNotificationDetails android = AndroidNotificationDetails(
'high_importance_channel', 'High Importance Notifications',
'high_importance_channel', // Use the same ID as before
'High Importance Notifications',
importance: Importance.high,
priority: Priority.high,
styleInformation: bigTextStyleInformation,
@@ -94,17 +94,17 @@ class NotificationController extends GetxController {
// Callback when the notification is tapped
void onDidReceiveNotificationResponse(NotificationResponse response) {
_handleNotificationResponse(response);
handleNotificationResponse(response);
}
// Callback when the notification is tapped while the app is in the background
void onDidReceiveBackgroundNotificationResponse(
NotificationResponse response) {
_handleNotificationResponse(response);
handleNotificationResponse(response);
}
// Handle notification response for both foreground and background
void _handleNotificationResponse(NotificationResponse response) {
void handleNotificationResponse(NotificationResponse response) {
print('Notification tapped!');
Log.print('response.payload: ${response.payload}');
if (response.payload != null) {