Skip to content

Commit

Permalink
Background tasks are now ended in their expiration handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzoq authored and bonzoq committed Mar 9, 2015
1 parent ebb7da0 commit 840ce66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
7 changes: 6 additions & 1 deletion Location/BackgroundTaskManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ -(UIBackgroundTaskIdentifier)beginNewBackgroundTask
{
UIApplication* application = [UIApplication sharedApplication];

UIBackgroundTaskIdentifier bgTaskId = UIBackgroundTaskInvalid;
__block UIBackgroundTaskIdentifier bgTaskId = UIBackgroundTaskInvalid;
if([application respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)]){
bgTaskId = [application beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"background task %lu expired", (unsigned long)bgTaskId);

[self.bgTaskIdList removeObject:@(bgTaskId)];
[application endBackgroundTask:bgTaskId];
bgTaskId = UIBackgroundTaskInvalid;

}];
if ( self.masterTaskId == UIBackgroundTaskInvalid )
{
Expand Down

0 comments on commit 840ce66

Please sign in to comment.