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

2.9k views Asked by At

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

3

There are 3 answers

0
Vakas On BEST ANSWER

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

0
Aneeq Anwar On

Currently, it is NOT possible to get the device's auto-lock time that is defined in device settings.

0
Ramsy de Vos On

Currently not possible, you can measure it yourself by calling and timing the following two functions

- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application