Xamarin essentials dosent have all the permisions I need

Viewed 67

I have a xamarin forms app, that needs to ask some specific permission that are not in the Xamarin essentials documentation, for example Bluetooth.

In IOS I did a Class that handles this

  public class BluetoothService : IBluetoothService
    {
        public Task<PermissionStatus> CheckPermissionAsync()
        {
            switch (CBManager.Authorization)
            {
                case CBManagerAuthorization.AllowedAlways:
                    return Task.FromResult(PermissionStatus.Granted);
                case CBManagerAuthorization.Restricted:
                    return Task.FromResult(PermissionStatus.Restricted);
                case CBManagerAuthorization.NotDetermined:
                    return Task.FromResult(PermissionStatus.Unknown);
                default:
                    return Task.FromResult(PermissionStatus.Denied);
            }
        }

        public async Task<PermissionStatus> RequestPermissionAsync()
        {
            // Initializing CBCentralManager will present the Bluetooth permission dialog.
            new CBCentralManager();
            PermissionStatus status;
            do
            {
                status = await CheckPermissionAsync();
                await Task.Delay(200);
            } while (status == PermissionStatus.Unknown);
            return status;
        }
    }

how can I do this as well for android and check the status in a button

0 Answers
Related