Alex Stone
Alex Stone

Reputation: 47354

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

Upvotes: 2

Views: 3129

Answers (3)

Ramsy de Vos
Ramsy de Vos

Reputation: 1072

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

- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application

Upvotes: -1

Aneeq Anwar
Aneeq Anwar

Reputation: 1332

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

Upvotes: 0

Vakas
Vakas

Reputation: 6472

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

Upvotes: 6

Related Questions