Reputation: 245
Hi I want to run my app in background until I quit it.For that I have used the code below
bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{
dispatch_async(dispatch_get_main_queue(), ^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
}];
but it quits after particular time.Can any one guide me to achieve this.
Upvotes: 2
Views: 373
Reputation: 69499
You don't!
Apple will allow you to complete a lengthy operation, but it is not ment to keep your app running. This will drain your battery.
There are three kind of background running apps support by Apple: Audio player, VOIP client and location based apps. Location based apps will only receive major location updates and only one audio player can run at a time.
Mis use of the background mode will get you app rejected.
Upvotes: 2
Reputation: 8109
wont work this way. your application need to support one of the background modes in a proper way
Upvotes: 1