By implementing a timer in the background as follows and using Xcode 4.5.2
UIDevice *device = [UIDevice currentDevice]; BOOL backgroundSupported = NO; if ([device respondsToSelector:@selector(isMultitaskingSupported)]) { backgroundSupported = YES; } if (backgroundSupported) { bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [[UIApplication sharedApplication] endBackgroundTask:bgTask]; }]; }
and my application is running in the background, and I have the above code in the applicationDidEnterBackground method in AppDelegate and getting the following message in gdb
Impossible endBackgroundTask: the background task does not exist with identifier 4, or it may already be completed. Break in UIApplicationEndBackgroundTaskError () for debugging.
I know this question is similar to Cannot endBackgroundTask , but there is no answer or suggestions. any ideas?
ios objective-c
Sharme
source share