Aller directement au contenu

Démarrage

Fenêtre de terminal
bun add @capgo/capacitor-keep-awake
bunx cap sync
import { KeepAwake } from '@capgo/capacitor-keep-awake';

Empêcher l'écran de s'éteindre.

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

Autoriser l'écran à s'éteindre (désactiver keep awake).

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

Vérifiez si la fonctionnalité de maintien éveillé est prise en charge sur la plateforme actuelle.

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

Vérifiez si le dispositif est actuellement maintenu éveillé.

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

Résultat de la méthode isSupported().

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

Résultat de la méthode isKeptAwake().

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

Cette page est générée à partir du plugin’s src/definitions.tsRe-run the sync when the public API changes upstream.