@@ -190,7 +190,9 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur
190
190
191
191
if (@available (iOS 14.0 , *)) {
192
192
if (
193
+ #if ! TARGET_OS_VISION
193
194
_lastUpdatedAuthorizationStatus == kCLAuthorizationStatusAuthorizedAlways ||
195
+ #endif
194
196
_lastUpdatedAuthorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse
195
197
) {
196
198
[self startMonitoring ];
@@ -202,16 +204,24 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur
202
204
203
205
- (void )startMonitoring
204
206
{
205
- _usingSignificantChanges
206
- ? [_locationManager startMonitoringSignificantLocationChanges ]
207
- : [_locationManager startUpdatingLocation ];
207
+ #if !TARGET_OS_VISION
208
+ _usingSignificantChanges
209
+ ? [_locationManager startMonitoringSignificantLocationChanges ]
210
+ : [_locationManager startUpdatingLocation ];
211
+ #else
212
+ [_locationManager startUpdatingLocation ];
213
+ #endif
208
214
}
209
215
210
216
- (void )stopMonitoring
211
217
{
212
- _usingSignificantChanges
213
- ? [_locationManager stopMonitoringSignificantLocationChanges ]
214
- : [_locationManager stopUpdatingLocation ];
218
+ #if !TARGET_OS_VISION
219
+ _usingSignificantChanges
220
+ ? [_locationManager stopMonitoringSignificantLocationChanges ]
221
+ : [_locationManager stopUpdatingLocation ];
222
+ #else
223
+ [_locationManager stopUpdatingLocation ];
224
+ #endif
215
225
}
216
226
217
227
#pragma mark - Timeout handler
@@ -273,22 +283,26 @@ - (void)timeout:(NSTimer *)timer
273
283
274
284
// Request location access permission
275
285
if (wantsAlways) {
286
+ #if !TARGET_OS_VISION
276
287
[_locationManager requestAlwaysAuthorization ];
277
288
[self enableBackgroundLocationUpdates ];
289
+ #endif
278
290
} else if (wantsWhenInUse) {
279
291
[_locationManager requestWhenInUseAuthorization ];
280
292
}
281
293
}
282
294
283
295
- (void )enableBackgroundLocationUpdates
284
296
{
297
+ #if !TARGET_OS_VISION
285
298
// iOS 9+ requires explicitly enabling background updates
286
299
NSArray *backgroundModes = [[NSBundle mainBundle ] objectForInfoDictionaryKey: @" UIBackgroundModes" ];
287
300
if (backgroundModes && [backgroundModes containsObject: @" location" ]) {
288
301
if ([_locationManager respondsToSelector: @selector (setAllowsBackgroundLocationUpdates: )]) {
289
302
[_locationManager setAllowsBackgroundLocationUpdates: YES ];
290
303
}
291
304
}
305
+ #endif
292
306
}
293
307
294
308
@@ -445,7 +459,9 @@ - (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager
445
459
}
446
460
447
461
if (
462
+ #if !TARGET_OS_VISION
448
463
currentStatus == kCLAuthorizationStatusAuthorizedAlways ||
464
+ #endif
449
465
currentStatus == kCLAuthorizationStatusAuthorizedWhenInUse
450
466
) {
451
467
if (_queuedAuthorizationCallbacks != nil && _queuedAuthorizationCallbacks.count > 0 ){
0 commit comments