@@ -15,32 +15,24 @@ namespace eShopOnContainers.iOS.Services
1515{
1616 public class LocationServiceImplementation : ILocationServiceImplementation
1717 {
18- public double DesiredAccuracy { get ; set ; }
19- public bool IsGeolocationAvailable => true ;
20- public bool IsGeolocationEnabled
21- {
22- get
23- {
24- var status = CLLocationManager . Status ;
25- return CLLocationManager . LocationServicesEnabled ;
26- }
27- }
18+ Lazy < IPermissionsService > _permissionsService ;
2819
2920 public LocationServiceImplementation ( )
3021 {
3122 DesiredAccuracy = 100 ;
23+ _permissionsService = new Lazy < IPermissionsService > ( ( ) => new PermissionsService ( ) , LazyThreadSafetyMode . PublicationOnly ) ;
3224 }
3325
3426 #region Internal Implementation
3527
3628 async Task < bool > CheckPermissions ( Permission permission )
3729 {
38- var status = await PermissionsService . Current . CheckPermissionStatusAsync ( permission ) ;
30+ var status = await _permissionsService . Value . CheckPermissionStatusAsync ( permission ) ;
3931 if ( status != PermissionStatus . Granted )
4032 {
4133 Console . WriteLine ( "Currently do not have Location permissions, requesting permissions" ) ;
4234
43- var request = await PermissionsService . Current . RequestPermissionsAsync ( permission ) ;
35+ var request = await _permissionsService . Value . RequestPermissionsAsync ( permission ) ;
4436 if ( request [ permission ] != PermissionStatus . Granted )
4537 {
4638 Console . WriteLine ( "Location permission denied, can not get positions async." ) ;
@@ -61,6 +53,17 @@ CLLocationManager GetManager()
6153
6254 #region ILocationServiceImplementation
6355
56+ public double DesiredAccuracy { get ; set ; }
57+ public bool IsGeolocationAvailable => true ;
58+ public bool IsGeolocationEnabled
59+ {
60+ get
61+ {
62+ var status = CLLocationManager . Status ;
63+ return CLLocationManager . LocationServicesEnabled ;
64+ }
65+ }
66+
6467 public async Task < Position > GetPositionAsync ( TimeSpan ? timeout , CancellationToken ? cancelToken = null )
6568 {
6669 var permission = Permission . LocationWhenInUse ;
0 commit comments