Command to set Auto-Lock to Never

Is there any Swift command to actually set the Auto-Lock to Never or a specific time period? I want to create a simple app that only has two buttons: one is to set the Auto-Lock to Never and the other one is to set it back to iOS default (1 min).

So when a user open this app and tap the Never button, s/he can open other apps but the iPhone or iPad will never auto lock while running the other apps. If s/he is done with other apps, s/he can open this app again and tap the Default button to set the Auto-Lock back to 1 min.

I understand this can be done from the Settings but I am just curious how I can do it from the backend using Swift.

I am new to Swift, btw.

Thanks much!

I think you should post this question in the Apple Developer forums, since its a question about Apple frameworks/API and isn’t related to the Swift language.

2 Likes