2

Can we programmatically lock and unlock Screen of the iPhone?

Heard of GSEventLockDevice() (private API) from GraphicsServices.framework but is not working in higher iOS versions.

Please checkout the following video: https://vimeo.com/188356953

Don't know how the iPhone screen is getting locked programatically in Cellcontrol ! Any ideas are welcomed !

swathy krishnan
  • 916
  • 9
  • 22

2 Answers2

1

We can't lock the screen programmatically without any private API but your requirement can achieve by sending keyboard events from paired bluetooth hardware devices.

Please check this link Force lock screen

Community
  • 1
  • 1
Anshad Rasheed
  • 2,526
  • 1
  • 14
  • 32
-3

There is no documentation given by Apple to do it. But there are some private API's which can be possible to do it but it is not accepted by Apple when you submit your app to AppStore.

So be specific on it whether you are going to submit in AppStore or Private purpose.

But you can keep your device unlock from auto lock by using the below line.

[UIApplication sharedApplication].idleTimerDisabled = YES;
Santo
  • 1,611
  • 3
  • 17
  • 37