Просмотр исходного кода

Fix LocationWhenInUse permission

Mathieu Acthernoene 6 лет назад
Родитель
Сommit
c013fb81f8

+ 7
- 5
ios/PermissionHandlers/LocationWhenInUse/RNPermissionHandlerLocationWhenInUse.m Просмотреть файл

@@ -22,7 +22,7 @@
22 22
   if (![CLLocationManager locationServicesEnabled]) {
23 23
     return resolve(RNPermissionStatusNotAvailable);
24 24
   }
25
-  
25
+
26 26
   switch ([CLLocationManager authorizationStatus]) {
27 27
     case kCLAuthorizationStatusNotDetermined:
28 28
       return resolve(RNPermissionStatusNotDetermined);
@@ -39,13 +39,15 @@
39 39
 - (void)requestWithOptions:(__unused NSDictionary * _Nullable)options
40 40
               withResolver:(void (^)(RNPermissionStatus status))resolve
41 41
               withRejecter:(void (^)(NSError *error))reject {
42
-  if ([CLLocationManager locationServicesEnabled] != kCLAuthorizationStatusNotDetermined) {
42
+  CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
43
+
44
+  if (status != kCLAuthorizationStatusNotDetermined) {
43 45
     return [self checkWithResolver:resolve withRejecter:reject];
44 46
   }
45
-  
47
+
46 48
   _resolve = resolve;
47 49
   _reject = reject;
48
-  
50
+
49 51
   _locationManager = [CLLocationManager new];
50 52
   [_locationManager setDelegate:self];
51 53
   [_locationManager requestWhenInUseAuthorization];
@@ -56,7 +58,7 @@
56 58
     _initialChangeEventFired = true;
57 59
   } else {
58 60
     [self checkWithResolver:_resolve withRejecter:_reject];
59
-    
61
+
60 62
     [_locationManager setDelegate:nil];
61 63
     _locationManager = nil;
62 64
   }