Я пытаюсь выяснить, почему locationManager:didUpdateLocations:
не запускается при использовании значительного изменения местоположения при блокировке устройства.Значительные изменения местоположения не срабатывают должным образом, когда устройство заблокировано
До сих пор locationManager:didUpdateLocations:
уволено с нового места только после Пробуждение устройства путем нажатия кнопки «домой».
Я использую iOS 8.1, но не знаю, является ли это нормальным поведением.
Это мой код (AppDelegate.m):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]){
NSLog(@"LAUNCHED BY LOCATION UPDATE");
}
[self startLocationTrack];
}
-(void)startLocationTrack
{
if (_locationManager == nil) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.pausesLocationUpdatesAutomatically = NO;
_locationManager.activityType = CLActivityTypeAutomotiveNavigation;
_locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
if ([_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[_locationManager requestAlwaysAuthorization];
}
[_locationManager startMonitoringSignificantLocationChanges];
}else{
[_locationManager startMonitoringSignificantLocationChanges];
}
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)location
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:5]];
notification.timeZone = [NSTimeZone defaultTimeZone];
[notification setSoundName:UILocalNotificationDefaultSoundName];
notification.alertBody = @"YOU HAVE MOVE A SIGNIFICANT DISTANCE!!";
notification.alertAction = NSLocalizedString(@"Read Msg", @"Read Msg");
notification.applicationIconBadgeNumber=0;
notification.repeatInterval=0;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}