zzzzz
zzzzz

Reputation: 1239

How can I programmatically password lock my iphone screen?

I have so many similar questions but none of them answers my question.Most are unrelated. Here is my scenario.Suppose somebody stole your phone,he accidentally opened an application.When he clicks a button in the app the phone will be locked.Now the phone would ask for a security pin or a password.I was wondering how can I do that? The phone must remain locked even if the phone reboots.I just want a way lock the screen and make the iphone useless for that crook.I know apple doesnt provide such functionality.Are there any good private APIs available?

I am not looking for any app to do that,I want to do that through my code.

Upvotes: 1

Views: 2205

Answers (3)

Sumit Mundra
Sumit Mundra

Reputation: 3901

Apple will never approve of what you wish to do. Your app must be used in the Jailbreak mode.

You can do this by calling a Private framework on your project - GraphicsServices.framework. However, please note, this would never be accepted and approved by Apple. By calling GSEventLockDevice() method you can lock your iOS device easily. GSEventLockDevice() function resides in GSEvent.h. Hope this helps.

Upvotes: 6

tilo
tilo

Reputation: 14169

You don't need an app for this, as you can already use iCloud for this purpose: iCloud: Lock and track your device

More specifically, you can't do it on your own (unless you are jailbreaking your phone), as iOS apps are sandboxed and may not limit access to the whole system.

Upvotes: 5

Nikola Kirev
Nikola Kirev

Reputation: 3152

You can password protect your app, but not the whole phone. To lock the whole phone, the user can set passcode from Settings->General->Passcode Lock. The apps are sandboxed, so you don't have access to the passcode from your app.

Upvotes: 0

Related Questions