0

There are many view controllers in my application. It's a social network. And I need to change one of images of the application automatically if user didn't touch the screen for 10 minutes for instance.

My first idea is to detect touches on each screen and depending on that implement "auto away".

But may be easier way exists. May be I can detect touches of the entire device in my application.

Thank you in advance!

Paul T.
  • 4,938
  • 7
  • 45
  • 93
  • Look here: http://stackoverflow.com/questions/273450/iphone-detecting-user-inactivity-idle-time-since-last-screen-touch – Mikhail Viceman Feb 08 '13 at 10:23
  • Mikhail Viceman reference [http://stackoverflow.com/questions/273450/iphone-detecting-user-inactivity-idle-time-since-last-screen-touch][1] helped [1]: http://stackoverflow.com/questions/273450/iphone-detecting-user-inactivity-idle-time-since-last-screen-touch – Paul T. Feb 12 '13 at 07:45

2 Answers2

0

You need to be increasing some variable that will tell you when your session "will" expire (in session or database) everytime you enter a new page.

For example, you store:

current time + 10 minutes

Then you create a function that you will be using in each page, that checks if the current time is lower than the variable you stored, then the user has been away for more that then minutes.

Ivo Pereira
  • 3,410
  • 1
  • 19
  • 24
  • but that means, that I need to check that on each page, and it's not OK anyway, because user can click buttons on one page for 10 minutes – Paul T. Feb 08 '13 at 10:20
  • Yes, but you would need to do it if you want to check if the user is active in your app or not. If the user is clicking on buttons, you would need to create a function that would be called on a button click too. You need to register all the events you want the record data from, otherwise there is no way to have access to them. – Ivo Pereira Feb 08 '13 at 10:23
  • but may be there is a way to detect all the screen touches? – Paul T. Feb 08 '13 at 10:25
0

U need to keep a timer. start in didFinishLaunching. whenever user does anyinteraction reset the timer to 10mins. if user interaction is not there for 10mins timer will expire. Try this

Durgaprasad
  • 1,910
  • 2
  • 25
  • 44