Reputation: 1595
How can I assign actions on iOS when a user presses the home button (exit)? I want this for an app where uses user a login feature and I want, upon exit, the user to log out. I dont want to use a button for this.
Upvotes: 1
Views: 829
Reputation: 266
Write your actions in appDelegate
's "applicationDidEnterBackground
" method.
Upvotes: 1
Reputation: 3301
You can't exit an application programmatically, you can use exit(1)
, however it's not a good practice, chances are there for your apps to get rejected from Apple.
applicationDidEnterBackground
will be called for home button press. Try to handle everything here.
Upvotes: 2
Reputation: 1153
Use the method,
- (void)applicationDidEnterBackground:(UIApplication *)application
In your application's delegate.
Upvotes: 2