This commit is contained in:
Hamza-Ayed
2024-02-14 22:31:28 +03:00
parent bbd4ce792e
commit ea7a5bb931
28 changed files with 941 additions and 605 deletions

View File

@@ -0,0 +1,29 @@
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:get/get.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');
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) 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);
}
}