Mathieu Acthernoene 5 jaren geleden
bovenliggende
commit
798128be90
1 gewijzigde bestanden met toevoegingen van 8 en 0 verwijderingen
  1. 8
    0
      ios/Permissions/RNPLocation.m

+ 8
- 0
ios/Permissions/RNPLocation.m Bestand weergeven

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