0

enter image description here

Is there any way to disappear an running app on processing on iPhone? Like this photo below. e.g. App Store application is my own application. I wanna do disappear it when I double clicked the home button. Any help is appreciated!

Johnny
  • 1,112
  • 1
  • 13
  • 21
  • You can't kill an app programmatically if that is your question. But the user can kill your app if it's is running in the background and it can be released if the phone need memory for something else. – Vaionixx Jun 20 '16 at 08:15
  • Yeah,but I need a snippet of code to hide this application or kill it.How can I do that? – Johnny Jun 20 '16 at 08:28
  • As you said, why I can't kill an app programmatically? Does Apple non-supported API for killing its own application? – Johnny Jun 20 '16 at 08:31
  • Apple doesn't allow you to kill your own app. – Vaionixx Jun 20 '16 at 08:34
  • Does Apple support private API for developing it? – Johnny Jun 20 '16 at 08:43
  • Or I can do that on a breakjail iPhone? – Johnny Jun 20 '16 at 08:43
  • this can be answered here http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application – sazz Jun 20 '16 at 08:46
  • You can do whatever on a jailbroken phone. how to do it I have no idé. @sazz answer might work on a jailbroken. But like the comments says probably i big no no from apples side. So you can´t release it on the store – Vaionixx Jun 20 '16 at 09:05
  • Yea, you give a answer to me . Directly killed the process with code `exit(0)`. – Johnny Jun 20 '16 at 11:35
  • But I don't want to kill this app , my only need is to hide it in the process manager , instead of killing it.
    It looks like that it will not show when you double click the home button. Maybe it is difficult to manipulate.
    – Johnny Jun 20 '16 at 11:36

1 Answers1

1

If you want to kill your application you can call:

exit(0);

However the app will look like it crashed. Apple don't recommend calling this function

If you want to do it in style you have to use some undocumented methods in UIApplication class. add this to your header

@interface UIApplication (Private)
- (void)suspend;
@end

And then you can call it like tis

//this will animate the app to home screening won't quit it 
[[UIApplication sharedApplication] suspend];

You can set a timer after calling the method to quit the app

NSTimer* myTimer = [[NSTimer alloc] initWithFireDate:[NSDate date]                        
                                            interval:0.4                       
                                              target:self                        
                                            selector:@selector(suspendTimeout:)                        
                                            userInfo:nil                        
                                            repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];

- (void)suspendTimeout:(id)sender{
    exit(0);
}
Karim H
  • 1,543
  • 10
  • 24
  • Thanks for your answer.
    But I don't want to kill this application. I just want to hide it in the process manager on iPhone.
    So the step is:
    1.Open an application and keep it running. 2.Double click the home button 3.Hide this app from the process manager on iPhone instead of killing it.
    – Johnny Jun 20 '16 at 11:44
  • You need to use private frameworks which are not approved by apple – Karim H Jun 20 '16 at 14:22