How can I programmatically enable Guided Access (Kiosk mode) on an iPhone?

halfbit picture halfbit · Dec 15, 2014 · Viewed 14.7k times · Source

Question

How do I automate Guided Access mode on an iPhone? I will need to automate the enabling and removal of this feature

Background This application from the State of Iowa uses an iOS app to display your drivers license. The issue is that after handing your phone over to authorities, they have full access to the device.

If I have the source code to this, or a similar application, how can I require a password when switching out of temporary "Kiosk mode", so that photos, emails or text messages are not available from either the phone, or (ideally) from USB.

I found this similar solution for Android, but am now looking for an iOS solution

Answer

jrturton picture jrturton · Dec 19, 2014

You can enter and exit guided access mode from within your app. However, to do so the device has to be supervised, and have an MDM profile installed that has the app's bundle ID in the list of applications that can request guided access mode (the key is autonomousSingleAppModePermittedAppIDs.

Once that is done, to enter guided access you do this:

UIAccessibility.requestGuidedAccessSession(true){
    success in
    print("Request guided access success \(success)")
}