简体   繁体   English

iOS如何以编程方式读取设备的屏幕自动锁定超时时间?

[英]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. 为此,我们需要将内部超时与ipad屏幕锁定计时器进行比较。

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 请参阅下面的屏幕以获取我要读取的号码

在此处输入图片说明

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 iphone检测-用户不活动空闲时间-自-最后屏幕触摸

目前,它是不可能得到了在设备设置中定义的设备的自动锁定时间。

Currently not possible, you can measure it yourself by calling and timing the following two functions 目前尚无法解决,您可以通过调用和计时以下两个函数来自己进行测量

- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM