This commit is contained in:
Hamza-Ayed
2024-09-19 06:55:42 +03:00
parent 85ece97855
commit b09e0da403
22 changed files with 352 additions and 186 deletions

View File

@@ -14,11 +14,10 @@ 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('app_icon');
AndroidInitializationSettings('@mipmap/launcher_icon');
const InitializationSettings initializationSettings =
InitializationSettings(android: android);
@@ -175,3 +174,67 @@ class NotificationController extends GetxController {
// display a dialog with the notification details, tap ok to go to another page
}
}
// import 'package:flutter_local_notifications/flutter_local_notifications.dart';
// import 'package:get/get.dart';
// import 'package:timezone/data/latest.dart' as tz;
// import 'package:timezone/timezone.dart' as tz;
// class NotificationController extends GetxController {
// final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
// FlutterLocalNotificationsPlugin();
// @override
// void onInit() {
// super.onInit();
// initNotifications();
// tz.initializeTimeZones();
// }
// // Initializes the local notifications plugin
// Future<void> initNotifications() async {
// const AndroidInitializationSettings android =
// AndroidInitializationSettings('@mipmap/launcher_icon');
// const InitializationSettings initializationSettings =
// InitializationSettings(android: android);
// await _flutterLocalNotificationsPlugin.initialize(initializationSettings);
// }
// // Displays a notification with the given title and message
// void showNotification(
// String title, String message, String tone, String payLoad) async {
// AndroidNotificationDetails android = AndroidNotificationDetails(
// 'your channel id', 'your channel name',
// importance: Importance.max,
// priority: Priority.high,
// showWhen: false,
// sound: RawResourceAndroidNotificationSound(tone));
// NotificationDetails details = NotificationDetails(android: android);
// await _flutterLocalNotificationsPlugin.show(0, title, message, details);
// }
// // Schedules a notification for a specific time
// Future<void> scheduleNotification(
// String title, String body, DateTime scheduledTime) async {
// await _flutterLocalNotificationsPlugin.zonedSchedule(
// 0,
// title,
// body,
// tz.TZDateTime.from(scheduledTime, tz.local),
// const NotificationDetails(
// android: AndroidNotificationDetails(
// 'your_channel_id',
// 'your_channel_name',
// channelDescription: 'your_channel_description',
// importance: Importance.max,
// priority: Priority.high,
// showWhen: false,
// ),
// ),
// androidAllowWhileIdle: true,
// uiLocalNotificationDateInterpretation:
// UILocalNotificationDateInterpretation.absoluteTime,
// matchDateTimeComponents: DateTimeComponents.time,
// );
// }
// }