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


#1

Hi,

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.

Thanks,
Satish


#2

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.


#3

You should be able to catch one of the events listened here: http://docs.phonegap.com/en/3.0.0/cordova_events_events.md.html

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