I encountered a strange bug where UIAccessibilityIsGuidedAccessEnabled starts returning false even after guided access has been enabled in settings and I activated it by triple tapping the home button and successfully seeing the guided access is enabled message.
Here is a sample code to show what I am doing.
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(guidedAccessStatusChanged(notification:)), name: NSNotification.Name.UIAccessibilityGuidedAccessStatusDidChange, object: nil)
}
@objc func guidedAccessStatusChanged(notification: NSNotification) {
if UIAccessibilityIsGuidedAccessEnabled() {
print("Guided access is enabled")
} else {
// The program randomly started just displaying this even after guided access is enabled.
print("Guided access is disabled")
}
}
At first I thought it might be a timing issue and even tried delaying my guided access status check but that did not work either.