dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.63k stars 1.62k forks source link

Permissions.CheckStatusAsync<Permissions.Bluetooth> on iOS returns Granted when don't allow is chosen #22070

Open ckrutsinger opened 2 weeks ago

ckrutsinger commented 2 weeks ago

Description

status = await Permissions.CheckStatusAsync<Permissions.Bluetooth>(); is returning PermissionStatus.Granted even though I choose Not Allowed.

Steps to Reproduce

iOS ONLY

  1. Include this in Info.plist:
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>app collects location data to enable vehicle services including current location and event location</string>
  2. Upon app install, you should be prompted for Bluetooth permission, choose "Don't Allow". If not prompted, use Settings app to disallow Bluetooth for app
  3. After app launches, call await Permissions.CheckStatusAsync<Permissions.Bluetooth>() and response will be PermissionStatus.Granted instead of PermissionStatus.Denied Demo app will put the permission status into the click me button upon being clicked

Link to public reproduction project repository

demo app

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17.4

Did you find any workaround?

No workaround found.

Relevant log output

no relevant logs
phillippschmedt commented 2 weeks ago

@ckrutsinger You could try if you also get the issue with the latest MAUI version of 8.0.21: https://github.com/dotnet/maui/discussions/22059

ksoftllc commented 2 weeks ago

Today I tried on 8.0.21 and 8.0.14. Both still exhibit returning Granted even if Don't Allow is chosen at install. I wonder if the issue has anything to do with the presence of both permission tags in Info.plist:

    <key>NSBluetoothPeripheralUsageDescription</key>
        ...
    <key>NSBluetoothAlwaysUsageDescription</key>

On first launch after install, the app prompts with the string for Always usage. There is no prompt for the now deprecated Peripheral usage permission. So it is the Always usage I am not allowing. Is the permission check returning the Peripheral permission, which apparently doesn't require explicit authorization? await Permissions.CheckStatusAsync<Permissions.Bluetooth>(); doesn't have an option to inquire about the Always permission.

ckrutsinger commented 1 week ago

I have added a demo project which replicates the bug on latest MAUI version. See MainPage.xaml.cs

QianaJiao commented 1 week ago

Verified this issue with Visual Studio 17.10 Preview 5 (8.0.21&8.0.7). Can repro on iOS platform with sample project.