Zum Inhalt springen

Anfangen

Terminal-Fenster
bun add @capgo/capacitor-keep-awake
bunx cap sync
import { KeepAwake } from '@capgo/capacitor-keep-awake';

Verhindere, dass das Gerät die Bildschirmhelligkeit dämpft.

import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.keepAwake();
console.log('Screen will stay awake');

Erlaube dem Gerät, die Bildschirmhelligkeit zu dämpfen (Keep-Awake deaktivieren).

import { KeepAwake } from '@capgo/capacitor-keep-awake';
await KeepAwake.allowSleep();
console.log('Screen can now dim');

Überprüfen Sie, ob die Funktion zum Aufrechterhalten des Betriebs unterstützt wird, auf der aktuellen Plattform.

import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isSupported } = await KeepAwake.isSupported();
if (isSupported) {
console.log('Keep awake is supported');
}

Überprüfen Sie, ob das Gerät derzeit aufgeweckt wird.

import { KeepAwake } from '@capgo/capacitor-keep-awake';
const { isKeptAwake } = await KeepAwake.isKeptAwake();
console.log('Is kept awake:', isKeptAwake);

Ergebnis der Methode isSupported().

export interface IsSupportedResult {
/**
* Whether keep awake is supported on the current platform.
*
* @since 1.0.0
*/
isSupported: boolean;
}

Ergebnis der Methode isKeptAwake().

export interface IsKeptAwakeResult {
/**
* Whether the device is currently being kept awake.
*
* @since 1.0.0
*/
isKeptAwake: boolean;
}

Diese Seite wird aus dem Plugin generiert. src/definitions.tsRe-run the sync when the public API changes upstream.