I'm trying to build an messageExtension app and I want it to take a picture using the iphone camera. I know that I need to add the NSCameraUsageDescription in my Info.plist file and I have done that. I have tried to something similar with a normal ios app and it worked fine; however when I do it in my message app it does not work.
Here attached are some screenshots and the code i use to call to open the camera. I feel I've been running in circles so any ideas would help.
private func openCamera() {
print("open camera!!!!")
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // the user has already authorized to access the camera.
print("authorized")
self.setupCaptureSession()
case .notDetermined: // the user has not yet asked for camera access.
print("not det")
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted { // if user has granted to access the camera.
print("the user has granted to access the camera")
self.setupCaptureSession()
} else {
print("the user has not granted to access the camera")
self.handleDismiss()
}
}
case .denied:
print("the user has denied previously to access the camera.")
self.handleDismiss()
case .restricted:
print("the user can't give camera access due to some restriction.")
self.handleDismiss()
default:
print("something has wrong due to we can't access the camera.")
self.handleDismiss()
}
}