class LocationService { static async getDefaultParams() { check(PERMISSIONS.IOS.LOCATION_ALWAYS) .then(result => { switch (result) { case RESULTS.UNAVAILABLE: console.log( 'This feature is not available (on this device / in this context)', ); break; case RESULTS.DENIED: console.log( 'The permission has not been requested / is denied but requestable', ); break; case RESULTS.LIMITED: console.log('The permission is limited: some actions are possible'); return permissionStatus(); case RESULTS.GRANTED: return permissionStatus(); case RESULTS.BLOCKED: console.log('The permission is denied and not requestable anymore'); break; } }) .catch(error => { // … }); async function permissionStatus() { let location; try { // Get current location location = await Geolocation.getCurrentPosition( position => position.coords, error => { console.log(error.message); }, {enableHighAccuracy: true, timeout: 15000, maximumAge: 10000}, ); } catch (err) { console.log(err); } if (location) { // Return default params return { MachineName: 'iPhone 14', ApplicationVersion: '12.1.4', BatteryLevelPercent: '-100', DiskSpaceAvailableInMB: '82641.23', DiskSpaceSizeInMB: '233752.4', CarrierName: 'Unknown', DeviceModel: 'x86_64', BatteryState: 'Unknown', Latitude: location.latitude, AllowFirmwareUpgrade: 'true', ConnectionType: 'WiFi', OsVersion: '16.0', IsUploadNeeded: 'false', Longitude: location.longitude, DeviceType: 'iPhone', DeviceGuid: '1A5FAF66-EAA7-488A-A518-99321BB2FB59', }; } else { return undefined; } } } } export default LocationService;