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
22.13k stars 1.73k forks source link

Bluetooth Adapter State Issue on Mac After Upgrading MAUI Project to .NET 8 #20297

Open shristigautam opened 8 months ago

shristigautam commented 8 months ago

Description

After updating the MAUI project from .net7 to .net8, the functionality for accessing Bluetooth stopped working properly in Mac.

The native CBCentralManager state displays "Unauthorized," and the adapter state when utilizing [dotnet-bluetooth-le] (https://github.com/dotnet-bluetooth-le/dotnet-bluetooth-le?tab=readme-ov-file shows "Unavailable," despite Bluetooth being turned on. It is worth noting that the same code works as expected on Android and iOS.

Also worth noting that the bluetooth permission pop-up doesn't appear in Mac even though NSBluetoothAlwaysUsageDescription and Privacy - Bluetooth Peripheral Usage Description are added to the info.plist.

And, the ble.StateChanged event is not triggered in Mac, as compared to Android and iOS, where it is triggered when the device's bluetooth is turned on or off manually.

Steps to Reproduce

  1. Create a new MAUI project using .NET 8.
  2. Implement any Bluetooth connectivity library. Example: [dotnet-bluetooth-le](https://github.com/dotnet-bluetooth-le/dotnet-bluetooth-le)
  3. Or clone this repo -> maui-dotneteight-bt-issue
  4. Run the project in Mac-catalyst and observe the Bluetooth adapter's state compared to Android and iOS.

Link to public reproduction project repository

maui-dotneteight-bt-issue

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI version 7.x.x

Last version that worked well

7.0.100

Affected platforms

macOS

Affected platform versions

Version 14.3 (23D56)

Did you find any workaround?

Not yet

Relevant log output

No response

ghost commented 8 months ago

Hi @shristigautam. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 8 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

shristigautam commented 8 months ago

I have added a link to the repo in the original post with sample code and steps. Please check!

garrypeterson commented 7 months ago

I'm seeing the same issue as shristigautam.

kevinxufei commented 7 months ago

Verified this issue with Visual Studio For Mac 17.6.10 build 428. Can repro on iOS/Maccatalyst platforms with sample project, but it works fine on android platform. a1

KunalKshatriya commented 4 months ago

Same issues, is there any update on when the fix will be available?

BiomeEd commented 3 months ago

Same issues, upgrade to .net 8 brakes the macOS app