Mathieu Acthernoene 4 years ago
parent
commit
798128be90
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      ios/Permissions/RNPLocation.m

+ 8
- 0
ios/Permissions/RNPLocation.m View File

@@ -19,6 +19,10 @@
19 19
 
20 20
 + (NSString *)getStatusForType:(NSString *)type
21 21
 {
22
+    if (![CLLocationManager locationServicesEnabled]) {
23
+        return RNPStatusRestricted;
24
+    }
25
+
22 26
     int status = [CLLocationManager authorizationStatus];
23 27
     switch (status) {
24 28
         case kCLAuthorizationStatusAuthorizedAlways:
@@ -36,6 +40,10 @@
36 40
 
37 41
 - (void)request:(NSString*)type completionHandler:(void (^)(NSString *))completionHandler
38 42
 {
43
+    if (![CLLocationManager locationServicesEnabled]) {
44
+        return completionHandler(RNPStatusRestricted);
45
+    }
46
+
39 47
     NSString *status = [RNPLocation getStatusForType:nil];
40 48
     if (status == RNPStatusUndetermined) {
41 49
         self.completionHandler = completionHandler;