Skip to content

MediaPicker.CapturePhotoAsync() fails with UnauthorisedAccessException on IOS despite successfully being Granted Access #34661

@mwilson25

Description

@mwilson25

Description

Not sure if I missed the memo and I need to do something else to make this work?

I have just upgraded one of my IOS MAUI app to .Net 10. I now find my users are blocked from accessing the Camera via the App despite being asked to grant permission and then granting that permission. Checking the IOS device Settings Page indicates Permission for the Camera has been granted

Here is my Code

async void OnCapturePhotoClicked(object sender, EventArgs e)
{
    try
    {
        FileResult file = await MediaPicker.CapturePhotoAsync();
        if (file != null)
        {
            await AddJobImageAttachment(file);
        }
    }
    catch (UnauthorizedAccessException)
    {
        await DisplayAlertAsync("Camera Access", "Camera access is not currently allowed", "OK");
    }
}

In the plist file I have

NSCameraUsageDescription
Job Image Camera
NSPhotoLibraryUsageDescription
Job Image Photo Library

Also happens on the Simulator for iPhone 16 IOS 18.4

My 9.0.10 version of one of my similar apps still works.

Steps to Reproduce

  1. Create a new MAUi App
  2. Add the Plist enties above for the IOS entries
  3. Add a button and Add my above code
  4. Run the Simulator
  5. Press the button
  6. Agree to permission
  7. Fails with UnauthorisedAccessException

Link to public reproduction project repository

No response

Version with bug

10.0.50

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.10 SR1

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No work around

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions