-1

I want to lock the device home screen programatically from my app. Is it possible in IOS?

In my app, if the user is idle for 1 minute, i want to lock the device. This is the scenario.

Thanks Jithen

Coder
  • 1,661
  • 4
  • 27
  • 50
  • you mean if user one minute idle then from home scren any thing not enable to go inside right?? – Paras Joshi Dec 03 '12 at 11:23
  • No, If user is in my app and if user kept the device idle in my app, then i want to lock the phone after 1 minute. – Coder Dec 03 '12 at 11:24
  • 1
    You can't... Public API doesn't allow this :) – Atif Azad Dec 03 '12 at 11:27
  • [UIApplication sharedApplication].idleTimerDisabled = YES, this too wont work? Paras said it works.. – Coder Dec 03 '12 at 11:29
  • NO... if you setIdleTimerDisabled:YES, it will even disable screen lock timer set in device settings. Your task is actually to lock it after one minute – Atif Azad Dec 03 '12 at 12:12
  • This has been discussed in detail here - http://stackoverflow.com/questions/832940/programmatically-lock-and-unlock-iphone-screen – ozarius Dec 03 '12 at 16:23

2 Answers2

1

you can lock the phone using bellow code

[UIApplication sharedApplication].idleTimerDisabled = YES;
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • then try this [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ]; – Paras Joshi Dec 03 '12 at 11:34
  • where you try this code?? means in timer after 1 minute this method or this code call ?? – Paras Joshi Dec 03 '12 at 11:38
  • @ParasJoshi, Jithen wants to lock screen after one minute and if you setIdleTimerDisabled:YES, it will even disable screen lock timer set in device settings. – Atif Azad Dec 03 '12 at 12:11
  • then see this answer may you can get some idea http://stackoverflow.com/questions/832940/programmatically-lock-and-unlock-iphone-screen i hope this help you – Paras Joshi Dec 04 '12 at 04:41
  • This piece of code does not do what you are suggesting. [UIApplication sharedApplication].idleTimerDisabled = YES; will keep your phone from going into the locked state on its own while your app is running. – Yup. Oct 21 '14 at 19:42
0

You can lock your own App by Adding a block view on Appdelegate's window. But locking your device is the responsibility of OS. I think if you somehow implement this then still aplle might reject your app on it. enter image description here

Abid Hussain
  • 1,529
  • 1
  • 15
  • 33