문제

Slightly confused on this one so I broke it down to a test app.

Simple singleton handling locationManager. I have turned on location support in the background under capabilities. Map is also enabled.

The location manager is running all the time but as soon as I put the application in to the background, it pauses.

I have read many posts about people trying to start location manager in the background, but mine is already running. I assumed by enabling it under capabilities, it would continue to run in the background. As soon as the app resumes, so does location manager.

Do I need to start looking in to beginBackgroundTaskWithExpirationHandler?

UPDATE

The code works in 7.06 and not 7.1.1? what did they change?

도움이 되었습니까?

해결책

I believe you must set your applications background modes to allow location updates. To do this edit your apps .plist file and add "location" as a "Required background mode" see the Apple docs for more background modes (here)

다른 팁

in appDelegete.m

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [locationmanger startUpdatingLocation];//start your location update method here

//then add this code 
 backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        [self endBackgroundTask];
    }];
}

-(void) endBackgroundTask
{
    [[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
    backgroundTask = UIBackgroundTaskInvalid;
}

it will work now

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top