Do action upon exit of ios app
-
30-06-2021 - |
Question
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.
Solution
Use the method,
- (void)applicationDidEnterBackground:(UIApplication *)application
In your application's delegate.
OTHER TIPS
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.
Write your actions in appDelegate
's "applicationDidEnterBackground
" method.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow