I want my app to decide whether sleep mode should be enabled by checking how many bluetooth peripherals are connected. For bluetooth I created a Singleton, which contains an array of all the connected peripherals. To disable sleep mode I found the following line of code online:
UIApplication.shared.isIdleTimerDisabled = true
Since the state of the sleep mode should always be updated after the number of connected peripherals changed, I could not figure out where to put that line of code.
Sorry if that's a novice question, but I am pretty new to programming, so I would appreciate any help. Maybe there is a better way to achieve the wanted behavior and I would be happy to learn about it.
Thanks in advance.