How to Programmatically Enable Guided Access (Kiosk Mode) on an Iphone

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

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)")
}

Check if kiosk mode is enable ( Guided access)

I add on didFinishLaunchingWithOptions
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(guidedAccessStatusChanged) name:UIAccessibilityGuidedAccessStatusDidChangeNotification object:nil];

-(void) guidedAccessStatusChanged {

if (UIAccessibilityIsGuidedAccessEnabled()) {
[Connexion consumeCallBackCompoTrainEnableAccess : @"true"];
} else {
[Connexion consumeCallBackConduiteEnableAccess : @"false"];

}

}

+ (void) consumeCallBackConduiteEnableAccess : (NSString *) hasAcess {

if(callbackStockConduite != nil && callbackStockConsommedConduite == false && [hasAcess isEqualToString:@"false"]){

callbackStockConsommedConduite = true;
callbackStockConduite(@[hasAcess]);

}

}

This callbackStockConduite is used by reactnative

How can I programmatically disable iphone home button in swift 4?

For kids, there is a feature in the iPhone setting called "Guided Access" this setting lock the phone with one app. This could be helpful for you. You can mention this in your app.

You can use this API to do programmatically. It was introduced in WWDC 2017. For more information how to use API and lock in a specific way. Please check this video. For doing programmatically without any device management it has been explained at 15:40th minute.



Related Topics



Leave a reply



Submit