LivePhotos taken with iPhone13 cannot be saved on iOS11 iPhone
The application incorporates a function to send image data between iPhones and save it to PhotoLibrary on the receiving iPhone side.
We receive the image data and save it in PhotoLibrary from the URL where the data is located, following the method on Apple's official website to save LivePhotos in PhotoLibrary.
However, when I receive LivePhotos taken by iPhone13 and try to save them in the same way on iPhone7 (iOS11), I get the following error and cannot complete the process
"error The operation couldn’t be completed. (Cocoa error -1.)"
func saveLivePhotoToPhotosLibrary(stillImageData: Data, livePhotoMovieURL: URL) { PHPhotoLibrary.requestAuthorization { status in
guard status == .authorized else { return }
PHPhotoLibrary.shared().performChanges({
let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: .photo, data: stillImageData, options: nil)
let options = PHAssetResourceCreationOptions()
options.shouldMoveFile = true
creationRequest.addResource(with: .pairedVideo, fileURL: livePhotoMovieURL, options: options)
}) { success, error in
// Handle completion.
}
}
}
When I send the same LivePhotos data via AirDrop, I also get an error message and cannot migrate it.
Does iOS11 not support LivePhotos on the latest iPhones?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Since the application cannot detect when the image picker is activated, it uses recursive processing to get the topmost View, and then executes the Delegate process after it is activated.
The following code is implemented in our own dialog, and detects the end of the image picker when the user selects "Select Photo".
extension DataSelectViewController: UIImagePickerControllerDelegate & UINavigationControllerDelegate {
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
Debug.log("image picker - taped Cancel")
		/* Added my process */
picker.dismiss(animated: true, completion: nil)
}
func imagePickerController(_: UIImagePickerController, didFinishPickingMediaWithInfo _: [UIImagePickerController.InfoKey: Any]) {
Debug.log("image picker - taped Done")
/* Added my process */
}
}
The delegate process may not be executed.
What are the possible factors?
When importing more than 1000 images in iOS9, a few images show "The file "IMG----.JPG" couldn't be opened because you don't have permission to view it. The file "IMG.JPG" couldn't be opened because you don't have permission to view it" appears for a few photos, and they cannot be imported.
The images in Photolibrary are retrieved by PHAsset.fetchAssets.
In iOS 10.3.3 or later, the same program does not cause this problem.
I checked the log to see if the URL or Asset was nil, but I didn't find anything wrong with the images that were successfully loaded.
Some of the codes we are getting are listed below.
Swift
private func _getAssetOption() - PHFetchOptions {
let option = PHFetchOptions()
option.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
option.includeAssetSourceTypes = .typeUserLibrary
option.includeAllBurstAssets = true
return option
}
private func _getAssets() - PHFetchResultPHAsset {
return PHAsset.fetchAssets(with: .image, options: _getAssetOption())
}
Prerequisite
When the user sets the media permission status to ".limited" and no data is selected.
In my environment, you can select "Select Photos..." from that state. in the process to grant additional permissions.
Problem symptoms
I am trying to start loading data immediately after the image picker closes for selection, but sometimes the images that I have granted additional permissions for do not load.
Assuming that additional permissions need time to be applied, I added a delay process and it worked fine.
Is it possible that it takes time for the OS to apply the permissions when there is no data selected in ".limited" and then added?