UIApplication.shared.isIdleTimerDisabled not working in Swift Playgrounds on iPad

Hello,

I'm currently working on an iPadOS app using Swift Playgrounds, and I'm encountering an issue related to the UIApplication.shared.isIdleTimerDisabled property. The app I'm developing has a fullscreen mode, and when this is active I want to prevent the screen from dimming and locking automatically.

I have tried multiple solutions to disable the idle timer when the app enters fullscreen mode, but none of them seem to be working within the Swift Playgrounds environment on my iPad. Here's a summary of the approaches I've tried:

  1. Using a property observer in the view model to update UIApplication.shared.isIdleTimerDisabled when an isFullScreen property changes.
  2. Using an onReceive modifier in the view to observe changes to an isFullScreen property and update UIApplication.shared.isIdleTimerDisabled accordingly.
  3. Creating a Timer to periodically simulate touch events, in an attempt to keep the screen awake.

Unfortunately, none of these solutions have been successful in preventing the screen from dimming and locking while running the app within Swift Playgrounds on my iPad.

My question is: Is there any restriction on the use of UIApplication.shared.isIdleTimerDisabled in the Swift Playgrounds on iPad? I wondered if this behavior might be the result of the app being launched within the Playgrounds environment.

If so, is there any workaround to achieve the desired behavior of preventing the screen from dimming and locking in fullscreen mode? If not, is there any other approach that would work in this scenario?

I’m very new to swift so there’s a good chance that there’s something I’m misunderstanding, but I wanted to rule this out as a possibility.

I’m on an iPad Pro (12.9-inch) (6th generation), iPadOS 16.3.1, Playgrounds 4.2.1

Any help or suggestions would be greatly appreciated!

UIApplication.shared.isIdleTimerDisabled not working in Swift Playgrounds on iPad
 
 
Q