I've been officially notified that iOS 17.2 contains the new API to officially support volume button actuation for photo capture in a camera app.
API is called AVCaptureEventInteraction
Link
So If I use the AVCam sample code, How would I be able to attach this interaction?
    if #available(iOS 17.2, *) {
       let interaction = AVCaptureEventInteraction { event in
             print ("AVCaptureEventInteraction Fired")
       }
    }
API does not contain any details.
                        
You would need to integrate
AVCaptureEventInteractioninto theAVCaptureSessionor a related component.The API usage could look like this:
But, since the
AVCaptureEventInteractionAPI documentation is not detailed, you might need to experiment with where to add this interaction within theAVCaptureSessionsetup. A likely place is right after initializing the session and before starting it.I tried a quick search on GitHub... and found nothing(!)
You could try and add the
AVCaptureEventInteractioninitialization in theconfigureSessionmethod of theAVCamsample, after setting up the session but before starting it.Inside the closure of
AVCaptureEventInteraction, implement the logic to capture a photo when the volume button is pressed. Add the interaction to theAVCaptureSession.Replace
self.capturePhoto()with the actual method used in AVCam to capture a photo.