diff --git a/lib/services/server_service.dart b/lib/services/server_service.dart index b61ca55..d0a0835 100644 --- a/lib/services/server_service.dart +++ b/lib/services/server_service.dart @@ -11,7 +11,13 @@ class ServerService { // Server always registers on startup to get fresh operational seed - GeolocationData geolocationData = await getGeolocationData(); + GeolocationData? geolocationData; + try { + geolocationData = await getGeolocationData(); + } catch (e) { + print('Warning: Failed to get geolocation data: $e'); + print('Proceeding with registration without geolocation data'); + } // Generate registration rolling code String registrationAuth = RollingCodesService.generateRegistrationCode(); @@ -22,7 +28,11 @@ class ServerService { Map requestBody = { 'server_id': fromEnivronment('SERVER_ID')!, 'registration_auth': registrationAuth, - 'geolocation_data': { + }; + + // Add geolocation data if available + if (geolocationData != null) { + requestBody['geolocation_data'] = { "country": geolocationData.countryName, "country_code": geolocationData.countryCode, "city": geolocationData.city, @@ -30,8 +40,8 @@ class ServerService { geolocationData.latitude, geolocationData.longitude ], - } - }; + }; + } try { final response = await http.post(