This is normal behavior.
Apple sandboxing will not let you turn on the flash while your app is in the background.
There is no workaround if we are not talking about a jailbroken application.
Edit:
Apple is very tough on using system APIs. Especially when it comes to:
- User privacy
- Battery Life
- User experience
In the case of a flashlight, the last two elements are relevant. Apple will not allow the device to drain the battery, if not in the foreground, and iOS users are used to make the flashlight, camera, microphone ... immediately turn off when switching to the background (excluding the microphone in some background cases).
To respond to a comment on your original post, iOS controls your hardware. Since Apple decided that they do not want the light to remain on when the user closes the application, iOS will simply turn off the flash when your application leaves the background. Your application is not authorized to prevent it.
Quentin hayot
source share