Lompat ke Konten

Mulai

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

Mencegah perangkat dari menurunkan kecerahan layar.

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

Mengizinkan perangkat untuk menurunkan kecerahan layar (nonaktifkan keep awake).

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

Periksa apakah fitur tetap terjaga aktif di platform saat ini.

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

Periksa apakah perangkat saat ini sedang tetap terjaga aktif.

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

Hasil dari metode isSupported().

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

Hasil dari metode isKeptAwake().

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

Halaman ini dibuat dari plugin’s src/definitions.tsRe-run sinkronisasi ketika publik API berubah di atas