This handler in my photo app:
cameraController.captureImage(){ ( image: UIImage?, error: Error? ) in
// This closure is the completion handler, it is called when the picture taking is completed.
if let error = error {
print( "camera completion handler called with error: " + error.localizedDescription )
}else{
print( "camera completion handler called." )
}
// If no image was captured return here:
guard let image = image else {
print(error ?? "Image capture error")
return
}
var phpPhotoLib = PHPhotoLibrary.shared()
if( phpPhotoLib.unavailabilityReason.debugDescription != "nil" ){
print( "phpPhotoLib.unavailabilityReason.debugDescription = " + phpPhotoLib.unavailabilityReason.debugDescription )
}else{
// There will be a crash right here unless the key "Privacy - Photo Library Usage Description" exists in this app's .plist file
try? phpPhotoLib.performChangesAndWait{
PHAssetChangeRequest.creationRequestForAsset(from: image)
}
}
}
asks the user for permission to store the captured photo data in the library. It does this once. It does not ask on subsequent photo captures. Is there a way for app to bypass this user permission request dialog, or at least present it to the user in advance of triggering a photo capture when the app first runs?
In this situation the camera is being used to capture science data in a laboratory setting. The scientist using this app already expects, and needs, the photo to be stored. The redundant permission request dialog makes the data collection cumbersome, and inconvenient, due to the extra effort required to reach the camera where it is located.