How to implement Daemon process for background task in iphone sdk 3.0?

Like qik.com or ustream.com, when they upload content from the iphone to the server, it works through the daemon. Thus, even when exiting the application, the task is still enabled with background daemons. Is there any method that I could implement the daemon process in the same way? Thank you !!!

+5
source share
7 answers

iPhone OS does not allow adding background processes.

+9
source

More likely, On Exit, they save state, then they are transferred to Launch resume.

+6
source

Block stream on applicationWillTerminate: will not be killed in a short time, but will be rejected by the App Store. For apps other than AppStore or personal, here is the code:

@interface MyApplication : UIApplication { BOOL _isApplicationSupposedToTerminate; } @property (assign) BOOL isApplicationSupposedToTerminate; - (void)_terminateWithStatus:(int)status; @end @implementation MyApplication @synthesize isApplicationSupposedToTerminate = _isApplicationSupposedToTerminate; - (void)_terminateWithStatus:(int)status { if (self.isApplicationSupposedToTerminate) { [super _terminateWithStatus:status]; } else { return; } } @end 

In main.m

  int retVal = UIApplicationMain(argc, argv, @"MyApplication", nil); 

Delegate:

 - (void)applicationWillTerminate:(UIApplication *)application { [(MyApplication*)application setIsApplicationSupposedToTerminate:!kIsTransferDone]; } 

This will terminate the application if your transfer fails. It is very important to set a timer for the verification timeout. And in applicationDidReceiveMemoryWarning: exit your application:

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { [(MyApplication*)application setIsApplicationSupposedToTerminate:YES]; [application terminateWithSuccess]; }

This should help you finish the job. For jailbreak only.

+5
source

Unfortunately, you cannot create a background process using the iPhone SDK. You can only download data while the application is running.

+2
source

The Deamon service is the best service, not the other services or background processing concept in iphone. Please follow the link below.
http://chrisalvares.com/blog/?tag=iphone-daemon

+1
source
+1
source

If the data needs to be sent, I will wait until the transfer is completed in the WillTernimate: application. As far as I know, the application will not be terminated if you block the thread in applicationWillTerminate. (Correct me if I am wrong). But be careful, if the data is huge or the speed of the Internet Internet user is crap, you should still go out and resume the transfer the next time. Set a timer to check for a timeout.

Caution: This may be rejected by the App Store.

0
source

Source: https://habr.com/ru/post/923113/


All Articles