-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Support for bluetooth permission #30729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for Bluetooth permission handling on iOS and macOS platforms within the .NET MAUI Essentials library. The implementation creates a new Bluetooth permission class that leverages CoreBluetooth framework APIs to check and request Bluetooth permissions.
Key changes:
- Implements platform-specific Bluetooth permission class for iOS/macOS
- Adds required public API surface to support the new permission type
- Uses CoreBluetooth's CBCentralManager to handle permission status and requests
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Essentials/src/Permissions/Permissions.ios.cs | Implements the core Bluetooth permission class with status checking and request functionality |
| src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Documents new public API methods for iOS platform |
| src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Documents new public API methods for macOS Catalyst platform |
Comments suppressed due to low confidence (1)
src/Essentials/src/Permissions/Permissions.ios.cs:157
- The new Bluetooth permission class lacks test coverage. Please ensure that test cases are added to TestCases.HostApp and TestCases.Shared.Tests to validate the permission checking and requesting functionality.
public partial class Bluetooth : BasePlatformPermission
| public partial class Bluetooth : BasePlatformPermission | ||
| { | ||
| static CBCentralManager CentralManager; |
Copilot
AI
Jul 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The static CBCentralManager field should be disposed properly to avoid potential memory leaks. Consider implementing IDisposable or adding a disposal mechanism.
| public partial class Bluetooth : BasePlatformPermission | |
| { | |
| static CBCentralManager CentralManager; | |
| public partial class Bluetooth : BasePlatformPermission, IDisposable | |
| { | |
| static CBCentralManager CentralManager; | |
| private static bool disposed = false; |
Copilot uses AI. Check for mistakes.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
aa4f1f0 to
8ce6e7e
Compare
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase and try use the cake target to generate these
/Users/builder/azdo/_work/1/s/src/Essentials/src/Permissions/Permissions.ios.cs(167,5): error RS0016: Symbol '~override Microsoft.Maui.ApplicationModel.Permissions.Bluetooth.RequiredInfoPlistKeys.get -> System.Func<System.Collections.Generic.IEnumerable>' is not part of the declared public API (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net10.0-maccatalyst18.5]
/Users/builder/azdo/_work/1/s/src/Essentials/src/Permissions/Permissions.ios.cs(169,43): error RS0016: Symbol '~override Microsoft.Maui.ApplicationModel.Permissions.Bluetooth.CheckStatusAsync() -> System.Threading.Tasks.Task<Microsoft.Maui.ApplicationModel.PermissionStatus>' is not part of the declared public API (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net10.0-maccatalyst18.5]
/Users/builder/azdo/_work/1/s/src/Essentials/src/Permissions/Permissions.ios.cs(192,43): error RS0016: Symbol '~override Microsoft.Maui.ApplicationModel.Permissions.Bluetooth.RequestAsync() -> System.Threading.Tasks.Task<Microsoft.Maui.ApplicationModel.PermissionStatus>' is not part of the declared public API (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net10.0-maccatalyst18.5]
/Users/builder/azdo/_work/1/s/src/Essentials/src/Permissions/Permissions.ios.cs(167,5): error RS0016: Symbol '~override Microsoft.Maui.ApplicationModel.Permissions.Bluetooth.RequiredInfoPlistKeys.get -> System.Func<System.Collections.Generic.IEnumerable>' is not part of the declared public API (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net10.0-ios18.5]
/Users/builder/azdo/_work/1/s/src/Essentials/src/Permissions/Permissions.ios.cs(169,43): error RS0016: Symbol '~override Microsoft.Maui.ApplicationModel.Permissions.Bluetooth.CheckStatusAsync() -> System.Threading.Tasks.Task<Microsoft.Maui.ApplicationModel.PermissionStatus>' is not part of the declared public API (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net10.0-ios18.5]
/Users/builder/azdo/_work/1/s/src/Essentials/src/Permissions/Permissions.ios.cs(192,43): error RS0016: Symbol '~override Microsoft.Maui.ApplicationModel.Permissions.Bluetooth.RequestAsync() -> System.Threading.Tasks.Task<Microsoft.Maui.ApplicationModel.PermissionStatus>' is not part of the declared public API (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md) [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net10.0-ios18.5]
105 Warning(s)
6 Error(s)
8ce6e7e to
3abf348
Compare
|
@rmarinho done and the cake seems to be working fine! :) |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run MAUI-DeviceTests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Failing test unrelated |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issues Fixed
Fixes #22070