Once permissions are configured in the corresponding OS of the application, call the ValidateBluetoothStatus() of the DigiBLEManager class to verify the necessary interfaces—as well as Bluetooth permissions—are enabled and granted.
| If any permission is required but not granted, this method performs the corresponding request to the user automatically. |
| Method | Description |
|---|---|
ValidateBluetoothStatus() |
Validates that Bluetooth is operative in the device. This means that necessary interfaces and permissions are enabled and granted. The method requests for permissions to the user if necessary. |
The ValidateBluetoothStatus() method may fail for the following reasons:
-
Any required interface (Bluetooth or GPS) is required but is not enabled, throwing a DigiIoTException.
-
Any required permission (Bluetooth or Location) is required but was not granted by the user, throwing a DigiIoTException.
try
{
// Verify that Bluetooth status is OK.
DigiBLEManager.ValidateBluetoothStatus();
}
catch (DigiIoTException ex)
{
// Display an alert with the error from the validation process.
MainThread.BeginInvokeOnMainThread(() =>
{
Shell.Current.DisplayAlert("Error checking Bluetooth", ex.Message, "OK");
});
}