Adding additional permissions for Bluetooth
- Dominant language
- No language data
- Stars
- 282
- Forks
- 265
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
[Enter feedback here]
Well this is a very interesting page if you have a PhD in computer science, but for me it is completely lacking in any useful detail on how to actually do it. I need to add Bluetooth permissions. As per usual with the documentation for .netMaui it assumes that peeps have a detailed knowledge of non basic code and actually it assumes they already know what to do to make things work, whereas I suspect the majority of people don't have a clue and need much more hand holding. Who wrote this stuff anyway - not someone who understands mere mortals that's for sure.
So far I have added a class called BluetoothPermissions.cs
```
namespace TSDZ2Monitor.Classes;
public class BluetoothPermissions : Permissions.BasePlatformPermission
{
public override (string androidPermission, bool isRuntime)[] RequiredPermissions =>
new List<(string androidPermission, bool isRuntime)>
{
(global::Android.Manifest.Permission.AccessCoarseLocation, true),
(global::Android.Manifest.Permission.AccessFineLocation, true),
(global::Android.Manifest.Permission.Bluetooth, true),
(global::Android.Manifest.Permission.BluetoothAdmin, true),
(global::Android.Manifest.Permission.BluetoothScan, true),
(global::Android.Manifest.Permission.BluetoothConnect, true),
(global::Android.Manifest.Permission.BluetoothAdvertise, true)
}.ToArray();
}
```
This is to match my AndroidManifest.xml
```
```
btw you need to let people know that the UPPERCASE in the manifest needs to be lowercase on the class!!!! Took me ages to accept that fix.
In my Pages>BluetoothPage.xaml.cs (i'm sure this isn't quite the place and probably not in the constructor, but hey it compiles
```
using InTheHand.Bluetooth;
using TSDZ2Monitor.Classes;
namespace TSDZ2Monitor.Pages;
public partial class BluetoothPage : ContentPage
{
public BluetoothPage()
{
InitializeComponent();
Console.WriteLine("Bluetooth here");
getBLEPermission();
static async void getBLEPermission()
{
//PermissionStatus status = await Permissions.CheckStatusAsync();
PermissionStatus status = await Permissions.RequestAsync();
if (status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync();
if (status != PermissionStatus.Granted)
{
//well kill the app because it's no use
return;
}
}
}
}
}
```
So not sure what to put at the
```
status = await Permissions.RequestAsync();
```
and I doubt it will work, because, well I don't really know why it won't, but you have an example of an unimplemented class with all sorts of things I'm supposed to do (MyPermissions?)
So can you please include a detailed example of how to implement Bluetooth rather than just some skeleton with no real example!
Thanks.
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: c978effc-e14b-bb58-464a-263059ce4413
* Version Independent ID: c978effc-e14b-bb58-464a-263059ce4413
* Content: [Permissions - .NET MAUI](https://docs.microsoft.com/en-us/dotnet/maui/platform-integration/appmodel/permissions?tabs=android)
* Content Source: [docs/platform-integration/appmodel/permissions.md](https://github.com/dotnet/docs-maui/blob/main/docs/platform-integration/appmodel/permissions.md)
* Product: **dotnet-mobile**
* Technology: **dotnet-maui**
* GitHub Login: @davidbritch
* Microsoft Alias: **dabritch**
Contributor guide
Assessment
This issue has not been assessed yet.