feat: Enhance background geofence functionality with notifications and localization support

This commit is contained in:
Achintha Isuru
2026-03-13 21:44:39 -04:00
parent 6f57cae247
commit 8fcf1d9d98
12 changed files with 188 additions and 56 deletions

View File

@@ -10,31 +10,18 @@ import 'package:krow_data_connect/krow_data_connect.dart';
import 'package:krowwithus_staff/firebase_options.dart';
import 'package:staff_authentication/staff_authentication.dart'
as staff_authentication;
import 'package:staff_clock_in/staff_clock_in.dart'
show backgroundGeofenceDispatcher;
import 'package:staff_main/staff_main.dart' as staff_main;
import 'package:workmanager/workmanager.dart';
import 'src/widgets/session_listener.dart';
/// Top-level callback dispatcher for background tasks.
///
/// Must be a top-level function because workmanager executes it in a separate
/// isolate where the DI container is not available.
@pragma('vm:entry-point')
void callbackDispatcher() {
Workmanager().executeTask((String task, Map<String, dynamic>? inputData) async {
// Background geofence check placeholder.
// Full implementation will parse inputData for target coordinates
// and perform a proximity check in the background isolate.
return true;
});
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
// Initialize background task processing for geofence checks
await const BackgroundTaskService().initialize(callbackDispatcher);
await const BackgroundTaskService().initialize(backgroundGeofenceDispatcher);
// Register global BLoC observer for centralized error logging
Bloc.observer = CoreBlocObserver(