google preperation 1
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:timezone/timezone.dart' as tz;
|
||||
import 'package:timezone/data/latest.dart' as tz;
|
||||
import 'package:flutter_timezone/flutter_timezone.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../services/app_settings.dart';
|
||||
import '../services/google_calendar_service.dart';
|
||||
|
||||
class NotificationService {
|
||||
@@ -92,6 +93,10 @@ class NotificationService {
|
||||
/// Fetches the calendar and reschedules all reminders. Call on app start
|
||||
/// and whenever notification settings change.
|
||||
Future<void> rescheduleFromCalendar() async {
|
||||
if (!AppSettings.instance.clubUnlocked) {
|
||||
await cancelAll(); // reminders are a club-member feature
|
||||
return;
|
||||
}
|
||||
final service = GoogleCalendarService();
|
||||
try {
|
||||
final now = DateTime.now();
|
||||
@@ -172,28 +177,6 @@ class NotificationService {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> scheduleTestNotification() async {
|
||||
try {
|
||||
await initialize();
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final isSlovenian = (prefs.getString('language') ?? 'English') == 'Slovenian';
|
||||
await _plugin.show(
|
||||
9999,
|
||||
isSlovenian ? 'Testno obvestilo' : 'Test Notification',
|
||||
isSlovenian ? 'Obvestila delujejo!' : 'Notifications are working!',
|
||||
_notifDetails,
|
||||
);
|
||||
final in10s = DateTime.now().add(const Duration(seconds: 10));
|
||||
await _scheduleNotification(
|
||||
id: 9998,
|
||||
title: isSlovenian ? 'Načrtovano testno obvestilo' : 'Scheduled Test',
|
||||
body: isSlovenian ? 'Načrtovana obvestila delujejo!' : 'Scheduled notifications are working!',
|
||||
scheduledDate: in10s,
|
||||
mode: await _scheduleMode(),
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> _scheduleNotification({
|
||||
required int id,
|
||||
required String title,
|
||||
|
||||
Reference in New Issue
Block a user