Description
Hello!
We are using MAUI essentials to capture images using the device's camera; in this case within iOS. It seems that, the permission "PhotoAddOnly" is requested upon calling CapturePhotoAsync, within the PhotoAsync task:
if (!pickExisting)
{
await Permissions.EnsureGrantedAsync<Permissions.PhotosAddOnly>();
}
r:101 - r:104 in maui/src/Essentials/src/MediaPicker/MediaPicker.ios.cs
As far as I know, but do correct me if I am wrong, this permission is only necessary for adding pictures to the device's library. But in our case, we are using this feature to simply capture a photo and use the given image's data to process it within our app, without saving it to the device's library.
The PhotoAsync task does not seem to add any data to the device's library either, which seems odd as it does require the permission to be set when capturing a picture.
I would suggest that this permission request is simply removed from the PhotoAsync task and (perhaps) added to the location where picture data would be stored within the device on it's internal library instead.
Otherwise, anyone using the MediaPicker for a similar situation would need to require the PhotosAddOnly permission inside the app, even if it isn't necessary.
Public API Changes
MediaPicker.ios.cs
public async Task<FileResult> PhotoAsync(MediaPickerOptions options, bool photo, bool pickExisting)
{
if (!photo && !pickExisting)
{
await Permissions.EnsureGrantedAsync<Permissions.Microphone>();
}
// Check if picking existing or not and ensure permission accordingly as they can be set independently from each other
if (pickExisting && !OperatingSystem.IsIOSVersionAtLeast(11, 0))
{
await Permissions.EnsureGrantedAsync<Permissions.Photos>();
}
if (!pickExisting)
{
await Permissions.EnsureGrantedAsync<Permissions.Camera>();
}
var vc = WindowStateManager.Default.GetCurrentUIViewController(true);
var tcs = new TaskCompletionSource<FileResult>();
if (pickExisting && OperatingSystem.IsIOSVersionAtLeast(14, 0))
{
var config = new PHPickerConfiguration
{
Filter = photo
? PHPickerFilter.ImagesFilter
: PHPickerFilter.VideosFilter
};
var picker = new PHPickerViewController(config)
{
Delegate = new Media.PhotoPickerDelegate
{
CompletedHandler = res =>
tcs.TrySetResult(PickerResultsToMediaFile(res))
}
};
PickerRef = picker;
}
else
{
// Removed permission request
var sourceType = pickExisting
? UIImagePickerControllerSourceType.PhotoLibrary
: UIImagePickerControllerSourceType.Camera;
var mediaType = photo ? UTType.Image : UTType.Movie;
if (!UIImagePickerController.IsSourceTypeAvailable(sourceType))
{
tcs.TrySetCanceled();
throw new FeatureNotSupportedException();
}
if (!UIImagePickerController.AvailableMediaTypes(sourceType).Contains(mediaType))
{
tcs.TrySetCanceled();
throw new FeatureNotSupportedException();
}
var picker = new UIImagePickerController
{
SourceType = sourceType,
MediaTypes = [mediaType],
AllowsEditing = false
};
if (!photo && !pickExisting)
{
picker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Video;
}
PickerRef = picker;
picker.Delegate = new PhotoPickerDelegate
{
CompletedHandler = async info =>
{
GetFileResult(info, tcs, options);
await picker.DismissViewControllerAsync(true);
}
};
}
Intended Use-Case
Using the CapturePhotoAsync (PhotoAsync task) for capturing an image, without the need for the PhotosAddOnly permission.
This allows users, like me and my team, to capture a picture and process it within the app, not needing to add the permission to the info.plist file.
The permission should be requested at the location where an application (that's using Maui.Essentials) would actually store the captured picture to the device's internal library, or when the app's developer actually does intend to save the image to the internal library.
Description
Hello!
We are using MAUI essentials to capture images using the device's camera; in this case within iOS. It seems that, the permission "PhotoAddOnly" is requested upon calling CapturePhotoAsync, within the PhotoAsync task:
As far as I know, but do correct me if I am wrong, this permission is only necessary for adding pictures to the device's library. But in our case, we are using this feature to simply capture a photo and use the given image's data to process it within our app, without saving it to the device's library.
The PhotoAsync task does not seem to add any data to the device's library either, which seems odd as it does require the permission to be set when capturing a picture.
I would suggest that this permission request is simply removed from the PhotoAsync task and (perhaps) added to the location where picture data would be stored within the device on it's internal library instead.
Otherwise, anyone using the MediaPicker for a similar situation would need to require the PhotosAddOnly permission inside the app, even if it isn't necessary.
Public API Changes
Intended Use-Case
Using the CapturePhotoAsync (PhotoAsync task) for capturing an image, without the need for the PhotosAddOnly permission.
This allows users, like me and my team, to capture a picture and process it within the app, not needing to add the permission to the
info.plistfile.The permission should be requested at the location where an application (that's using Maui.Essentials) would actually store the captured picture to the device's internal library, or when the app's developer actually does intend to save the image to the internal library.