0

I have an app. We login while using it. It's a multi-user app from the same device with one user at a time. When a user pushed the home button I need to quit the app, not go to background mode. When it goes to background mode it returns to the last active screen rather than the login screen the next tie someone clicks the app icon to enter the app.

How do I either:

close the app with home button press

or which method is called when the app becomes the foreground activity again from the background operation so I could write the code in there that I need to redirect the app to the login view?

Thanks!

Spanky
  • 4,980
  • 7
  • 36
  • 37
  • You can't force exit an app, however that seems irrelevant because "When it goes to background mode it returns to the last active screen rather than the login screen" is something you have control over - you know when the app comes to the foreground so just display whatever it is you want at that point. – Gruntcakes Oct 31 '16 at 19:02

2 Answers2

0

Whenever you hit home button, "applicationDidEnterbackground" method will be called. Assign nil to all the current user variables.

In "applicationWillEnterForeground" Method compare the values of all the current user variables.

If it is nil -> Launch login screen.

0

Go to your info.plist and add the key "Application does not run in background". This time when the user clicks the home button, the application exits completely.

Vinodh
  • 5,262
  • 4
  • 38
  • 68