iPhone собирает данные CoreMotion в фоновом режиме. (дольше 10 минут)

Я пытаюсь собирать данные ускорения CoreMotion в фоновом режиме более 10 минут. Это должно быть возможно, так как приложения, такие как Sleep Cycle, делают это.

Я просто хочу убедиться, что это разрешено, так как это, кажется, не один из них:

Apps that play audible content to the user while in the background, such as a music player app
Apps that record audio content while in the background.
Apps that keep users informed of their location at all times, such as a navigation app
Apps that support Voice over Internet Protocol (VoIP)
Apps that need to download and process new content regularly
Apps that receive regular updates from external accessories
Apps that implement these services must declare the services they support and use system frameworks to implement the relevant aspects of those services. Declaring the services lets the system know which services you use, but in some cases it is the system frameworks that actually prevent your application from being suspended.

Тем не менее, я попытался выполнить эти шаги, чтобы получить фоновую задачу, но я думаю, что есть лучший способ для CoreMotion:

Заголовок:

UIBackgroundTaskIdentifier bgTask; 

Код:

// if the iOS device allows background execution,
// this Handler will be called
- (void)backgroundHandler {

NSLog(@"### -->VOIP backgrounding callback");

UIApplication*    app = [UIApplication sharedApplication];

bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
    [app endBackgroundTask:bgTask];
    bgTask = UIBackgroundTaskInvalid;
}];

// Start the long-running task 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

while (1) {
    NSLog(@"BGTime left: %f", [UIApplication sharedApplication].backgroundTimeRemaining);
       [self doSomething];
    sleep(1);
}   
});     

- (void)applicationDidEnterBackground:(UIApplication *)application {

BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
if (backgroundAccepted)
{
    NSLog(@"VOIP backgrounding accepted");
}

UIApplication*    app = [UIApplication sharedApplication];

bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
    [app endBackgroundTask:bgTask];
    bgTask = UIBackgroundTaskInvalid;
}];


// Start the long-running task
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    while (1) {
        NSLog(@"BGTime left: %f", [UIApplication sharedApplication].backgroundTimeRemaining);
       [self doSomething];
       sleep(1);
    }    
}); 
}

Ответы на вопрос(1)

Ваш ответ на вопрос