Skip to content

Commit

Permalink
Background: Fix placement of log message
Browse files Browse the repository at this point in the history
The second value is only valid after starting the task
  • Loading branch information
guruz committed Apr 16, 2020
1 parent 75d335b commit 9df570b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions quassel-for-ios/quassel-for-ios/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void myExceptionHandler (NSException *exception)

- (void) endBgTask
{
NSLog(@"endBgTask %d", bgTask);
UIApplication *app = [UIApplication sharedApplication];
if (bgTask != UIBackgroundTaskInvalid) {
NSLog(@"BACKGROUNDHANDLER endBgTask Actually ending it %lu", (unsigned long)bgTask);
Expand All @@ -85,9 +86,7 @@ - (void) doForeground:(NSNotification *)aNotification {
- (void) doBackground:(NSNotification *)aNotification {
UIApplication *app = [UIApplication sharedApplication];


NSLog(@"BACKGROUNDHANDLER We entered the background, trying to postpone it, we would get killedin %f seconds", [app backgroundTimeRemaining]);
if ([app respondsToSelector:@selector(beginBackgroundTaskWithExpirationHandler:)]) {
NSLog(@"BACKGROUNDHANDLER We entered the background, trying to postpone it");
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
// Synchronize the cleanup call on the main thread in case
// the task actually finishes at around the same time.
Expand All @@ -102,8 +101,11 @@ - (void) doBackground:(NSNotification *)aNotification {
[selfCpy endBgTask];
});
}];
if (bgTask!=UIBackgroundTaskInvalid) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(@"BACKGROUNDHANDLER Will get killed in %f seconds", [app backgroundTimeRemaining]);
});
}

}


Expand Down

0 comments on commit 9df570b

Please sign in to comment.