Force user to login when app is suspended by using iOS home button



In my iOS project there is requirement to force user to login if he closes app or switch to another app by pressing home button.

Is there way to accomplish this?

I have tried <preference name="exit-on-suspend" value="true" /> key in config.xml, but it is not working.



Hi @satisht,

You should be able to accomplish this by using Apache Cordova event listeners. You basically listen to see if the app was resumed from the background and do something if it was. In your case, show a password prompt.

Event listeners can be set up in the modules run method.


You should be able to catch one of the events listened here:

I seem to recall that when I go in and out of my iOS app, it generates an active event.