I'm trying to get an app running indefinitely.. I'm developing an internal app, so apple approval doesnt matter.
I've tried a few different things, including simulating a voip app using this tutorial..
http://www.raywenderlich.com/29948/backgrounding-for-ios
Eventually I ran into this code snippet online
[application beginBackgroundTaskWithExpirationHandler:^{}];
I place this in beginBackgroundTaskWithExpirationHandler
and then call a slow-looping function inside of my app delegate in application:didFinishLaunchingWithOptions
-(void)caller{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
NSTimeInterval timeRemaining = [UIApplication sharedApplication].backgroundTimeRemaining;
NSLog(@"%f", timeRemaining);
[self caller];
});
}
this logs background time remaining every 3 seconds. it does this when i exit my app.. i see a countdown from 180 (3 minutes) to eventually 0
then it just keeps logging 0 indefinitely. I would figure if background time reaches zero, then my process wouldnt execute.
Anyone have any idea whats going on here?