| 
				
			 | 
			
			
				@@ -6,8 +6,6 @@ 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				 @interface RNPermissionHandlerLocationAlways() <CLLocationManagerDelegate> 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				 @property (nonatomic, strong) CLLocationManager *locationManager; 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				
			 | 
			
			
				-@property (nonatomic) bool initialChangeEventFired; 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				
			 | 
			
			
				-@property (nonatomic) bool isWaitingDidBecomeActive; 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				9
			 | 
			
			
				 @property (nonatomic, strong) void (^resolve)(RNPermissionStatus status); 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				10
			 | 
			
			
				 @property (nonatomic, strong) void (^reject)(NSError *error); 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				11
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -51,57 +49,22 @@ 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				49
			 | 
			
			
				   if (![CLLocationManager locationServicesEnabled] || ![RNPermissions isBackgroundModeEnabled:@"location"]) { 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				50
			 | 
			
			
				     return resolve(RNPermissionStatusNotAvailable); 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				51
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				-  CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-  if (status == kCLAuthorizationStatusAuthorizedAlways) { 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-    return resolve(RNPermissionStatusAuthorized); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+  if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusNotDetermined) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+    return [self checkWithResolver:resolve rejecter:reject]; 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				54
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				55
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				61
			 | 
			
				56
			 | 
			
			
				   _resolve = resolve; 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				57
			 | 
			
			
				   _reject = reject; 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-  _initialChangeEventFired = false; 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-  _isWaitingDidBecomeActive = false; 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				-  if (status == kCLAuthorizationStatusAuthorizedWhenInUse && ![RNPermissions isFlaggedAsRequested:[[self class] handlerUniqueId]]) { 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-    _isWaitingDidBecomeActive = true; 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-    [[NSNotificationCenter defaultCenter] addObserver:self 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-                                             selector:@selector(UIApplicationDidBecomeActiveNotification:) 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-                                                 name:UIApplicationDidBecomeActiveNotification object:nil]; 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-  } 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				58
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				74
			 | 
			
				59
			 | 
			
			
				   _locationManager = [CLLocationManager new]; 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				60
			 | 
			
			
				   [_locationManager setDelegate:self]; 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				61
			 | 
			
			
				   [_locationManager requestAlwaysAuthorization]; 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				62
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				63
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-- (void)onAuthorizationStatus { 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-  [RNPermissions flagAsRequested:[[self class] handlerUniqueId]]; 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				-  [self checkWithResolver:_resolve rejecter:_reject]; 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-  [_locationManager setDelegate:nil]; 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				-  _locationManager = nil; 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				-  if (_isWaitingDidBecomeActive) { 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				-    [[NSNotificationCenter defaultCenter] removeObserver:self 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				-                                                    name:UIApplicationDidBecomeActiveNotification 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				
			 | 
			
			
				-                                                  object:nil]; 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				
			 | 
			
			
				-  } 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				-- (void)UIApplicationDidBecomeActiveNotification:(NSNotification *)notification { 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				
			 | 
			
			
				-  if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse) { 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				-    [self onAuthorizationStatus]; 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				-  } 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				64
			 | 
			
			
				 - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				-  // @see https://github.com/iosphere/ISHPermissionKit/blob/2.1.2/ISHPermissionKit/Requests/ISHPermissionRequestLocation.m#L127 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-  if (status != kCLAuthorizationStatusNotDetermined && _initialChangeEventFired) { 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-    [self onAuthorizationStatus]; 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				-  } else { 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				-    _initialChangeEventFired = true; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+  if (status != kCLAuthorizationStatusNotDetermined) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+    [_locationManager setDelegate:nil]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+    [self checkWithResolver:_resolve rejecter:_reject]; 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				68
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				69
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				70
			 | 
			
			
				  
			 |