Search code examples
iosobjective-cdebuggingscreen-lockuser-inactivity

iOS how to programmatically read device's screen auto-lock timeout time?


I'm creating a method to send debug info to the support team for one of my apps. I have method calls like these:

 NSString* appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
 NSString* build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];;
 NSString* iOSVersion = [[UIDevice currentDevice] systemVersion];;

An additional requirement is to understand how our internal timeout interacts with the device's screen auto lock timer. To do so we need to compare our internal timeout with the ipad screen lock timer.

Is there a way to get the device's auto-lock time that is defined in device settings? See screen below for the number I'm trying to read

enter image description here


Solution

  • This isn't possible. Following link has some work around for this. Basically you can get the idle time in your app till the screen goes off which should be the same as device' auto-lock time.

    iphone-detecting-user-inactivity-idle-time-since-last-screen-touch