Browse Source

ignore the first call for didChangeAuthorization

Radu Popovici 9 năm trước cách đây
mục cha
commit
98eb47556b
1 tập tin đã thay đổi với 9 bổ sung11 xóa
  1. 9 11
      permissions/RNPLocation.m

+ 9 - 11
permissions/RNPLocation.m

@@ -37,18 +37,16 @@
 {
     NSString *status = [RNPLocation getStatus];
     if (status == RNPStatusUndetermined) {
-        dispatch_async(dispatch_get_main_queue(), ^(){
-            self.completionHandler = completionHandler;
+        self.completionHandler = completionHandler;
+        
+        self.locationManager = [[CLLocationManager alloc] init];
+        self.locationManager.delegate = self;
             
-            self.locationManager = [[CLLocationManager alloc] init];
-            self.locationManager.delegate = self;
-                
-            if ([type isEqualToString:@"always"]) {
-                [self.locationManager requestAlwaysAuthorization];
-            } else {
-                [self.locationManager requestWhenInUseAuthorization];
-            }
-        });
+        if ([type isEqualToString:@"always"]) {
+            [self.locationManager requestAlwaysAuthorization];
+        } else {
+            [self.locationManager requestWhenInUseAuthorization];
+        }
     } else {
         completionHandler(status);
     }