Prevent your screen from getting some sleep!
npm install @capacitor-community/keep-awake
@capacitor-community/keep-awake
⚡️ Capacitor plugin to prevent devices from dimming or locking the screen.
| Maintainer | GitHub | Social |
| ------------- | ----------------------------------------------- | ------------------------------------------------- |
| Kevin Boosten | kevinboosten | @kevinboosten |
| Robin Genz | robingenz | @robin_genz |
``shell`
npm install @capacitor-community/keep-awake
npx cap sync
No configuration required for this plugin.
A working example can be found in example-app folder.
`typescript
import { KeepAwake } from '@capacitor-community/keep-awake';
const keepAwake = async () => {
await KeepAwake.keepAwake();
};
const allowSleep = async () => {
await KeepAwake.allowSleep();
};
const isSupported = async () => {
const result = await KeepAwake.isSupported();
return result.isSupported;
};
const isKeptAwake = async () => {
const result = await KeepAwake.isKeptAwake();
return result.isKeptAwake;
};
`
* keepAwake()
* allowSleep()
* isSupported()
* isKeptAwake()
* Interfaces
`typescript`
keepAwake() => Promise
Prevent the device from dimming the screen.
--------------------
`typescript`
allowSleep() => Promise
Allow the device to dim the screen.
--------------------
`typescript`
isSupported() => Promise
Whether keep awake is supported or not.
Returns: Promise<IsSupportedResult>
--------------------
`typescript`
isKeptAwake() => Promise
Check if the device is kept awake.
Returns: Promise<IsKeptAwakeResult>
--------------------
#### IsSupportedResult
| Prop | Type |
| ----------------- | -------------------- |
| isSupported | boolean |
#### IsKeptAwakeResult
| Prop | Type |
| ----------------- | -------------------- |
| isKeptAwake` | boolean |
See CHANGELOG.md.
See LICENSE.