Device


How to use the device sensor classes of the bit Butil?

Usage
The device sensor features are spread across a few classes. Inject the ones you need and use them like this:
@inject Bit.Butil.Battery battery
@inject Bit.Butil.NetworkInformation networkInformation
@inject Bit.Butil.WakeLock wakeLock
@inject Bit.Butil.IdleDetector idleDetector

@code {
    var status = await battery.GetStatus();
    var net = await networkInformation.GetStatus();
}
Battery
The Battery class wraps the Battery Status API.

IsSupported:
Returns whether the Battery Status API is available in the current browser.



GetStatus:
Returns a snapshot of the battery charging state and level (MDN).

NetworkInformation
The NetworkInformation class wraps the Network Information API plus the always-available navigator.onLine flag.

GetStatus:
Returns the online flag, effective connection type, downlink and round-trip-time estimates.

WakeLock
The WakeLock class wraps the Screen Wake Lock API, which prevents the screen from dimming while the app is active.

Request / Release:
Acquires or releases a screen wake lock. RequestPersistent keeps the lock re-acquired automatically when the page becomes visible again.

IdleDetector
The IdleDetector class wraps the Idle Detection API (Chromium-based browsers, requires permission).

RequestPermission / Start:
Requests the idle-detection permission and starts watching the user/screen idle state until it is stopped.