I need to detect whenever another app is using the iPhone’s/iPad’s camera while my app is running. My app keeps on running in background (audio), but it does not use the camera itself. I just need to find out if another app is using any camera at all.
Moreover, I want to use as little CPU resources as possible to minimize battery usage.
I’ve tried without success:
- running a simple
AVCaptureSessionto catch interruption notifications (it’s never notified) - call
lockForConfigurationon allAVCaptureDevices - periodically monitor the
enabledproperty ofAVCaptureInputPort(it’s always YES) - periodically monitor the
connectedproperty ofAVCaptureDevice(it’s always YES)
For clarification:
- I do not need a way to detect existence of camera(s)
- I do not need a way to find out if the camera is active in my app
Thanks for any pointers.
EDIT: this a security feature: I want to warn the user if there’s a slight possibility that a malicious (foreground) app is taking a photo or video of the user or the surroundings while my app is in active (background) use.
The iOS documentation doesn’t say anything about a way your app can be notified when another app runs the camera. That doesn’t sound like something Apple would ever allow either. Besides, it wouldn’t do any good to know if another app is running the camera because: a) your app cannot use the camera if it’s not active, and b) your app cannot affect the operation of another app in any way. Try to think of an alternative to what you’re trying to achieve, because unfortunately, this way is impossible.