How to detect idle user in iphone-sdk

In my application, I want to call the exit function, if the user is idle for a certain amount of time, how to execute

this answer doesn’t work for me iPhone: detection of user inactivity / downtime since the last touch of the screen  if I subclass the application delegate class from UIApplication and implement

- (void)sendEvent:(UIEvent *)event

It gives me an error

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'

I cannot find another instance of UIApplication in my application

so far i have done

instead

@interface IdleAppDelegate : NSObject <UIApplicationDelegate> {

I changed it to

@interface IdleAppDelegate : UIApplication<UIApplicationDelegate> {

and basically instead

 int retVal = UIApplicationMain(argc, argv, nil, nil);

I changed it to

int retVal = UIApplicationMain(argc, argv, @"IdleAppDelegate", @"IdleAppDelegate");

Is there anything else?

I get the error above ... am I missing something ...?

Please, help

thank

+3
source share
2

- . UIApplicationMain() , - . - , UIApplication, , NSObject.

+2

-(void)applicationWillResignActive:(UIApplication *)application

{
    NSLog(@"Application not Active");
    // FETCH THE CURRENT TIME 
}
0

Source: https://habr.com/ru/post/1751374/


All Articles