1

I am using SimpleMDM to handle enable and disable single app mode for my application. App has a "unlockDevice" button. Once single app mode is enabled from MDM and the app has entered single app mode on iPad, app should exit single app mode on this unlockDevice button tap.

@IBAction func unlockDevice(_ sender: Any) {
        UIAccessibilityRequestGuidedAccessSession(false, { (didSucceed) -> Void in
            DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                if didSucceed == true {
                    let alert = UIAlertController.init(title: "Success", message: "Exited the Single App Mode", preferredStyle: .alert)
                    let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                    alert.addAction(okAction)
                    UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil)
                } else {
                    let alert = UIAlertController.init(title: "Failure", message: "Failed to exit Single App Mode. Please try again.", preferredStyle: .alert)
                    let okAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                    alert.addAction(okAction)
                    UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil)
                }
            }
        })
    }

I have passed false to UIAccessibilityRequestGuidedAccessSession but the app is not exiting from single app mode. How can I exit the single app mode?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Does it stay in single app mode _and_ succeed, or does the "Failure" alert show? – Ian MacDonald Dec 07 '18 at 17:22
  • The failure alert comes up and it stays in single app mode. – akshay tule Dec 07 '18 at 19:46
  • 1
    Does the configuration profile include your app's bundle ID in the list of applications that can request (and release) guided access mode? The key is `autonomousSIngleAppModePermittedAppIDs`, [and more information can be seen here](https://stackoverflow.com/a/27560356/981049). – Michael Dautermann Feb 26 '19 at 06:06

0 Answers0