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?