Implement Notifications and Pad Tracking Enhancements
This commit is contained in:
@@ -34,12 +34,13 @@ class NotificationService {
|
||||
requestBadgePermission: true,
|
||||
requestSoundPermission: true,
|
||||
);
|
||||
|
||||
|
||||
// Linux initialization (optional, but good for completeness)
|
||||
final LinuxInitializationSettings initializationSettingsLinux =
|
||||
LinuxInitializationSettings(defaultActionName: 'Open notification');
|
||||
|
||||
final InitializationSettings initializationSettings = InitializationSettings(
|
||||
final InitializationSettings initializationSettings =
|
||||
InitializationSettings(
|
||||
android: initializationSettingsAndroid,
|
||||
iOS: initializationSettingsDarwin,
|
||||
macOS: initializationSettingsDarwin,
|
||||
@@ -63,10 +64,10 @@ class NotificationService {
|
||||
required DateTime scheduledDate,
|
||||
}) async {
|
||||
if (kIsWeb) {
|
||||
// Web platform limitation: Background scheduling is complex.
|
||||
// For this demo/web preview, we'll just log it or rely on the UI confirmation.
|
||||
print('Web Notification Scheduled: $title - $body at $scheduledDate');
|
||||
return;
|
||||
// Web platform limitation: Background scheduling is complex.
|
||||
// For this demo/web preview, we'll just log it or rely on the UI confirmation.
|
||||
print('Web Notification Scheduled: $title - $body at $scheduledDate');
|
||||
return;
|
||||
}
|
||||
|
||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||
@@ -92,30 +93,72 @@ class NotificationService {
|
||||
|
||||
// New method for specific notification types
|
||||
Future<void> showLocalNotification({
|
||||
required int id,
|
||||
required String title,
|
||||
required String body,
|
||||
String? channelId,
|
||||
String? channelName,
|
||||
required int id,
|
||||
required String title,
|
||||
required String body,
|
||||
String? channelId,
|
||||
String? channelName,
|
||||
}) async {
|
||||
if (kIsWeb) {
|
||||
print('Web Local Notification: $title - $body');
|
||||
return;
|
||||
}
|
||||
const AndroidNotificationDetails androidNotificationDetails =
|
||||
AndroidNotificationDetails(
|
||||
'tracker_general', 'General Notifications',
|
||||
AndroidNotificationDetails('tracker_general', 'General Notifications',
|
||||
channelDescription: 'General app notifications',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
ticker: 'ticker');
|
||||
|
||||
|
||||
const NotificationDetails notificationDetails =
|
||||
NotificationDetails(android: androidNotificationDetails);
|
||||
|
||||
await flutterLocalNotificationsPlugin.show(
|
||||
id, title, body, notificationDetails,
|
||||
payload: 'item x');
|
||||
|
||||
await flutterLocalNotificationsPlugin
|
||||
.show(id, title, body, notificationDetails, payload: 'item x');
|
||||
}
|
||||
|
||||
Future<void> showPrayerRequestNotification(
|
||||
{required String senderName}) async {
|
||||
await showLocalNotification(
|
||||
id: 300,
|
||||
title: 'New Prayer Request',
|
||||
body: '$senderName sent you a prayer request. Tap to pray with them.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showTeachingPlanNotification(
|
||||
{required String teacherName}) async {
|
||||
await showLocalNotification(
|
||||
id: 302,
|
||||
title: 'New Teaching Plan',
|
||||
body: '$teacherName added a new teaching plan for you.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showPartnerUpdateNotification(
|
||||
{required String title, required String body}) async {
|
||||
await showLocalNotification(
|
||||
id: 305,
|
||||
title: title,
|
||||
body: body,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showCycleUpdateNotification({required String message}) async {
|
||||
await showLocalNotification(
|
||||
id: 310,
|
||||
title: 'Cycle Update',
|
||||
body: message,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showSymptomNotification(
|
||||
{required String senderName, required String symptom}) async {
|
||||
await showLocalNotification(
|
||||
id: 315,
|
||||
title: 'Partner Care Reminder',
|
||||
body: '$senderName logged $symptom. A little extra care might be nice!',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> cancelNotification(int id) async {
|
||||
|
||||
Reference in New Issue
Block a user