Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone session - timeout on inactivity

When the user successfully log into my app, session starts, after X period of inactivity the session will time out.

Now how do you detect, the user to see if his active using the application or not using it?

1) Check every on button?

2) check on screen load?

like image 303
001 Avatar asked Aug 29 '26 07:08

001


2 Answers

The most elegant way I've found to do this is to use a category on UIApplication that provides a sendEvent: method that resets an NSTimer (after calling its superclass implementation of course). If the timer goes off, post a notification. Listen for the notification everywhere you want to react to the timeout. Doing it this way means that you don't have to add code all through your app to reset the timer on every interaction.

Having said that, I agree with Shaggy Frog, this isn't typical behaviour for an iOS application, so it's not usually a good idea from a HCI perspective.

like image 110
Jim Avatar answered Aug 30 '26 23:08

Jim


If you're asking "How do I define activity", you could always reset a timer after a touch event is received, whose callback triggers the "user is inactive event".

I can't speak much for your overall design choice here, as I don't think most iOS users expect their apps to behave in this manner. Think of your users and proceed with caution.

like image 30
Shaggy Frog Avatar answered Aug 30 '26 22:08

Shaggy Frog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!