Forced application to close and run in the background

We have an application that has a specific purpose, where an exit is required. After exiting, the process should run in the background for a certain time or until completion. We just need to know how to programmatically make the application enter the background, where processes can continue to work. Any help on this would be great! Thanks in advance!

UPDATE. We have confirmed that there seems to be a software way to get the application not to close / enter the background and not perform background tasks. You can force close the application using exit (0); but it kills the application all together. However, the main part of this question concerned the completion of tasks in the background. We found a solution that allows our application to begin processing data and processing tasks that the user has to process. Here is the code needed. This needs to be added to the application delegate, and multitasking is required on the device / iOS.

- (void)applicationDidEnterBackground:(UIApplication *)app{ // Check that IOS supports multitasking if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]){ // Check that the device supports multitasking if ([[UIDevice currentDevice] isMultitaskingSupported]) { // Custom setting to allow users the freedom to enable or disable background tasks BOOL enabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"backgroundTasksEnabled_key"]; if ( enabled ){ //Get the shared application instance backGroundApp = [UIApplication sharedApplication]; background_task = [backGroundApp beginBackgroundTaskWithExpirationHandler: ^ { [backGroundApp endBackgroundTask: background_task]; background_task = UIBackgroundTaskInvalid; }]; // Run in background dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSLog(@"\n\nProcess background tasks!\n\n"); // Do your work here }); } } } } 
+2
source share
3 answers

You can block the iOS application in the background by sending the registered URL to another processing application, such as the website URL for Safari.

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString: myWebsiteURL ]]; 

Many apps that are called Safari for URL processing are Apple approved.

To get any time in the background, the application must be properly configured using one of the allowed background modes (audio, location or VOIP); or the application may request a few minutes of additional time in the background before pausing by calling the beginBackgroundTaskWithExpirationHandler method

+2
source

You cannot have a process doing work in the background in iOS, you get a few seconds when the application shuts down and does it!

0
source

You cannot force the application to the background, I am sure that Apple recommendations forbid you to do this. What can your application do, what can it do only in the background, and not in the foreground?

-1
source

All Articles