When I click the button, I want my app which is running in foreground needs to go to background. Is it possible? If so how?
Asked
Active
Viewed 115 times
0
-
http://stackoverflow.com/questions/33652978/programmatically-sending-an-app-to-background – Sahil Nov 08 '16 at 06:57
-
Found already, But it is not woking... – narayana MV Nov 08 '16 at 07:04
2 Answers
0
Warning: This is an private instance method. Your app may get rejected in the app store.
UIApplication *app = [UIApplication sharedApplication];
[app performSelector:@selector(suspend)];

Manishankar
- 327
- 1
- 12
-
what do we write inside suspend method to bring app to background from foreground? – narayana MV Nov 08 '16 at 07:11
0
@IBAction func bringToBackgroundButtonClicked(sender: UIButton)
{
let app = UIApplication.sharedApplication()
app.performSelector(#selector(self.suspend))
}
func suspend()
{
exit(0)
}
makes your app which is running in foreground will go to background.
This is not recommended, not sure about app store approval.

narayana MV
- 31
- 6