Search code examples
iosobjective-ctouch-event

Global Touch Event in ios


my question is related to touch event which is Global in app

This is my scenario,

I Have an App with 15 screens, When first screen launches the timer starts, User goes from one screen to another screen randomly, In that case i need to reset the timer, If timer reaches to (say 120 seconds ) i have to destroy the current user session and logout n starts from first screen.

The implementation code for startLogoutTimer resetLogoutTimer and stopLogoutTimer is in AppDelegate class, if User navigates to any screen and touches the screen, i need to execute the methods of startLogoutTimer, resetLogoutTimer and stopLogoutTimer based on action but without message call to AppDelegate from every class (Screen/ViewController).

Thank You.


Solution

  • My above Problem is Solved. I added the below code into AppDelegate class

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resetLogoutTimer) name:UITouchPhaseBegan object:nil];
    

    Now where ever I touch on screen, my timer restarts.