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.
source share