我正在使用SimpleMDM处理启用和禁用我的应用程序的单个应用程序模式。应用具有“ unlockDevice”按钮。一旦从MDM启用了单一应用程序模式,并且该应用程序已在iPad上进入单一应用程序模式,则该应用程序应在此unlockDevice按钮点击时退出单一应用程序模式。
@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)
}
}
})
}
我已将false传递给UIAccessibilityRequestGuidedAccessSession,但该应用程序未从单个应用程序模式退出。如何退出单应用程序模式?