Again I have a similar doubt as specified in the link setKeepAliveTimeout and BackgroundTasks.
I have to periodically take a file from server and accordingly provide local notification. This has to be done when app is in background state.
Again I have a similar doubt as specified in the link setKeepAliveTimeout and BackgroundTasks.
I have to periodically take a file from server and accordingly provide local notification. This has to be done when app is in background state.
Create backgoud task in your interface:
@property (nonatomic) UIBackgroundTaskIdentifier bgTask;
Than create method to backgroud working:
- (void) backgroundMethod {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//create backgriund task;
self.bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask: self.bgTask];
self.bgTask = UIBackgroundTaskInvalid;
}];
//do your stuff;
[[UIApplication sharedApplication] endBackgroundTask: self.bgTask];
self.bgTask = UIBackgroundTaskInvalid;
});
}
And call it whenewer you want periodicaly.