views:

171

answers:

1

Hi,

Is there a way to 'force' the user to have auto-lock (and maybe passcode lock) on while the application is running (for security reasons mainly)? If we can't set them programmatically, can we at least check to see if they are set?

Thanks, Mihai

+1  A: 
if ([UIApplication sharedApplication].idleTimerDisabled == YES) {
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Please enable auto-lock"...];
    [alert show];
    [alert release];
} else {
    /* some code */
}

The above snippet will check to see if the idle timer is disabled. If it is, it will tell the user to enable it via a UIAlertView.

esqew
idleTimerDisabled is always NO on iPad, no matter if Auto-Lock is set or not.
Mihai Fonoage
Really? I haven't seen anything saying so. Wouldn't you think Apple would document that?
esqew
I tested it on my iPad. I used "NSLog(@"idleTimerDisabled: %@", [ UIApplication sharedApplication ].idleTimerDisabled ? @"YES" : @"NO");" inside didFinishLaunchingWithOptions, and changed the Auto-Lock option from the Settings menu to "Never" and then to "2 Minutes".
Mihai Fonoage