Handle geolocation data retrieval failure and proceed with registration
This commit is contained in:
@@ -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<String, dynamic> 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(
|
||||
|
||||
Reference in New Issue
Block a user