initialize static method
Inicializa o serviço de sincronização em background
Implementation
static Future<void> initialize() async {
if (_isInitialized) return;
try {
// Inicializar WorkManager
await Workmanager().initialize(
callbackDispatcher,
isInDebugMode: kDebugMode,
);
// Inicializar serviço de notificações usando o SyncConfig
try {
final syncConfig = _getSyncConfig();
if (syncConfig != null && syncConfig.enableNotifications) {
await syncConfig.initializeNotifications();
}
} catch (e) {
// Fallback silencioso se SyncConfig não estiver disponível
SyncUtils.debugLog('Erro ao inicializar notificações: $e', tag: 'BackgroundSyncService');
}
_isInitialized = true;
SyncUtils.debugLog('BackgroundSyncService inicializado com sucesso', tag: 'BackgroundSyncService');
} catch (e) {
SyncUtils.debugLog('Erro ao inicializar BackgroundSyncService: $e', tag: 'BackgroundSyncService');
rethrow;
}
}