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
|
// 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
|
// Generate registration rolling code
|
||||||
String registrationAuth = RollingCodesService.generateRegistrationCode();
|
String registrationAuth = RollingCodesService.generateRegistrationCode();
|
||||||
@@ -22,7 +28,11 @@ class ServerService {
|
|||||||
Map<String, dynamic> requestBody = {
|
Map<String, dynamic> requestBody = {
|
||||||
'server_id': fromEnivronment('SERVER_ID')!,
|
'server_id': fromEnivronment('SERVER_ID')!,
|
||||||
'registration_auth': registrationAuth,
|
'registration_auth': registrationAuth,
|
||||||
'geolocation_data': {
|
};
|
||||||
|
|
||||||
|
// Add geolocation data if available
|
||||||
|
if (geolocationData != null) {
|
||||||
|
requestBody['geolocation_data'] = {
|
||||||
"country": geolocationData.countryName,
|
"country": geolocationData.countryName,
|
||||||
"country_code": geolocationData.countryCode,
|
"country_code": geolocationData.countryCode,
|
||||||
"city": geolocationData.city,
|
"city": geolocationData.city,
|
||||||
@@ -30,8 +40,8 @@ class ServerService {
|
|||||||
geolocationData.latitude,
|
geolocationData.latitude,
|
||||||
geolocationData.longitude
|
geolocationData.longitude
|
||||||
],
|
],
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
|
|||||||
Reference in New Issue
Block a user