5.0.0 • Published 24 days ago

@capacitor-community/keep-awake v5.0.0

Weekly downloads
980
License
MIT
Repository
github
Last release
24 days ago

Maintainers

MaintainerGitHubSocial
Kevin Boostenkevinboosten@kevinboosten
Robin Genzrobingenz@robin_genz

Installation

npm install @capacitor-community/keep-awake
npx cap sync

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

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;
};

API

keepAwake()

keepAwake() => Promise<void>

Prevent the device from dimming the screen.


allowSleep()

allowSleep() => Promise<void>

Allow the device to dim the screen.


isSupported()

isSupported() => Promise<IsSupportedResult>

Whether keep awake is supported or not.

Returns: Promise<IsSupportedResult>


isKeptAwake()

isKeptAwake() => Promise<IsKeptAwakeResult>

Check if the device is kept awake.

Returns: Promise<IsKeptAwakeResult>


Interfaces

IsSupportedResult

PropType
isSupportedboolean

IsKeptAwakeResult

PropType
isKeptAwakeboolean

Changelog

See CHANGELOG.md.

License

See LICENSE.