Files
jamshalat-diary/lib/main.dart
Dwindi Ramadhana 4badfb6521 Notification system audit: fix 6 defects, close 5 gaps, add rich notifications (v1.1.0)
Defects fixed:
- D1: Fix notification ID range collision (report reminders 700k→2M+)
- D2: Streak risk now checks both dzikir pagi & petang
- D3: _cancelPrayerPending no longer kills non-prayer notifications
- D4: Push notifications carry deeplink in payload for proper routing
- D5: Add reconfigureTimeZoneIfNeeded() for TZ change detection
- D6: Defer launch notification routing until widget tree is ready

Gaps closed:
- G1: Add streak risk + weekly summary toggles to settings UI
- G2: Verified boot reschedule already in place (flutter_local_notifications v21)
- G3: Remove unused mirrorAdzanToInbox field and legacy cleanup calls
- G4: Add notif_push_opened analytics tracking
- G5: Add notif_settings_changed analytics tracking

Enhancements:
- O1: Rich notification with Sudah Sholat action button on report reminders
- O2: Permission check on app resume via WidgetsBindingObserver (30s throttle)
- O2b: Fix stretched notification icon (white crescent moon vector drawable)
- O3: Expired inbox cleanup in background sync
- O4: Haptic feedback on notification bell quick actions

Bump version 1.0.8+9 → 1.1.0+10
2026-06-06 22:38:02 +07:00

64 lines
2.0 KiB
Dart

import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:just_audio_background/just_audio_background.dart';
import 'app/app.dart';
import 'data/local/hive_boxes.dart';
import 'data/local/models/app_settings.dart';
import 'data/services/notification_orchestrator_service.dart';
import 'data/services/remote_push_service.dart';
import 'data/services/background_sync_service.dart';
import 'data/services/notification_service.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Hive and open all boxes
await initHive();
// Load environment variables
await dotenv.load(fileName: '.env');
// Seed default settings and checklist items on first launch
await seedDefaults();
// Ensure intl DateFormat locale data is ready before any localized formatting.
await initializeDateFormatting('id_ID');
// Initialize local notifications for adzan/iqamah scheduling
await NotificationService.instance.init();
if (Platform.isAndroid || Platform.isIOS) {
await BackgroundSyncService.instance.init();
await BackgroundSyncService.instance.registerPeriodicSync();
}
await RemotePushService.instance.init();
// Run passive notification checks at startup (inbox cleanup/content sync).
final settingsBox = Hive.box<AppSettings>(HiveBoxes.settings);
final settings = settingsBox.get('default') ?? AppSettings();
unawaited(NotificationService.instance.syncHabitNotifications(
settings: settings,
));
unawaited(NotificationOrchestratorService.instance.runPassivePass(
settings: settings,
));
await JustAudioBackground.init(
androidNotificationChannelId: 'com.jamshalat.app.audio',
androidNotificationChannelName: 'Murattal Playback',
androidNotificationOngoing: true,
);
runApp(
const ProviderScope(
child: App(),
),
);
}