I have an app that records video (and also provides a custom remote interface) so it needs to remain awake and in the foreground.
It sets;
UIApplication.shared.isIdleTimerDisabled = true
I've also tried catching willEnterForegroundNotification to ensure it resets it if the app is backgrounded and resumes;
.onReceive(
NotificationCenter.default.publisher(
for: UIApplication.willEnterForegroundNotification)
) { _ in
UIApplication.shared.isIdleTimerDisabled = true
}
However, it seems that on some devices it will still go to sleep. This seems to be the case when Adaptive Power Mode is on (or rather, I've not managed to reproduce it when Adaptive Power Mode is off) even when battery percentage is well over 20% (I sort of expected Low Power Mode to trigger this)
Am I missing something obvious? there must be a way to make sure media capture apps stay awake (I'm surprised AVFoundation doesn't do it anyway!)
If it is related to Adaptive Power Mode, is there any way to detect that programatically to at least provide a warning to the user that having it on will affect operation of the app?