Reputation: 11951
I am using Xamarin.Forms and MediaPlugin https://github.com/jamesmontemagno/MediaPlugin and here is my code:
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await DisplayAlert("Photos Not Supported", "Sorry! Permission not granted to photos.", "OK");
return;
}
MediaFile file = null;
if (await Permissions.RequestAsync<Permissions.Photos>() == Xamarin.Essentials.PermissionStatus.Granted)
{
file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
});
}
if (file == null)
return;
var imageSource = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
PickImage.Source = imageSource;
This gives me a permission dialog like so:
When I select "Select Photos..." And then select the photos that i am allowing the app to use, the library comes up again and I am allow to select any photo I want, even the ones I did not select the first time around.
Is this the expected behaviour for Select Photos..., is there away I can remove the Select Photos... option?
Upvotes: 1
Views: 829
Reputation: 1304
That package is no longer mantained, so it's not sure that it works as intended.
You should migrate to Xamarin.Essentials MediaPicker. It will handle the permission request automatically for you.
Also it seems that you are already using Xamarin.Essentials.
Make sure that you follow the steps detailed on the documentation. That means modifying the info.plist
.
Upvotes: 1