KEMBAR78
[iOS] Support for bluetooth permission by kubaflo · Pull Request #30729 · dotnet/maui · GitHub
Skip to content

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jul 20, 2025

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

@Copilot Copilot AI review requested due to automatic review settings July 20, 2025 12:20
@kubaflo kubaflo requested a review from a team as a code owner July 20, 2025 12:20
@kubaflo kubaflo self-assigned this Jul 20, 2025
@kubaflo kubaflo added platform/ios area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info area-essentials-permissions community ✨ Community Contribution labels Jul 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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

Comment on lines +157 to +159
public partial class Bluetooth : BasePlatformPermission
{
static CBCentralManager CentralManager;
Copy link

Copilot AI Jul 20, 2025

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.

Suggested change
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.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@kubaflo kubaflo changed the base branch from main to net10.0 July 30, 2025 14:42
@kubaflo kubaflo force-pushed the ios-bluetooth-permission branch from aa4f1f0 to 8ce6e7e Compare July 30, 2025 22:37
@jfversluis
Copy link
Member

jfversluis commented Jul 31, 2025

/azp run MAUI-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@rmarinho rmarinho left a 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)

@rmarinho rmarinho moved this from Todo to Changes Requested in MAUI SDK Ongoing Aug 1, 2025
@rmarinho rmarinho added this to the .NET 10.0-rc1 milestone Aug 1, 2025
@kubaflo kubaflo force-pushed the ios-bluetooth-permission branch from 8ce6e7e to 3abf348 Compare August 1, 2025 13:38
@kubaflo
Copy link
Contributor Author

kubaflo commented Aug 1, 2025

@rmarinho done and the cake seems to be working fine! :)

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis jfversluis moved this from Changes Requested to Ready To Review in MAUI SDK Ongoing Aug 2, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Aug 7, 2025
@jfversluis
Copy link
Member

/azp run MAUI-DeviceTests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis
Copy link
Member

Failing test unrelated

@jfversluis jfversluis dismissed rmarinho’s stale review August 8, 2025 12:31

Build errors resolved

@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Aug 8, 2025
@jfversluis jfversluis merged commit c75d7cf into dotnet:net10.0 Aug 8, 2025
50 of 52 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Aug 8, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info area-essentials-permissions community ✨ Community Contribution p/0 Work that we can't release without platform/ios

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

5 participants