跳过内容

开始使用

安装

安装
终端窗口
bun add @capgo/capacitor-keep-awake
bunx cap sync

导入

导入
import { KeepAwake } from '@capgo/capacitor-keep-awake';

API概述

API概述

keepAwake

__keepAwake__

防止设备屏幕自动熄屏

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

allowSleep

__allowSleep__

允许设备屏幕自动熄屏

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

检查当前平台是否支持保持唤醒功能。

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

检查设备是否当前保持唤醒状态。

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

isSupported()方法的结果。

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

IsKeptAwakeResult

IsKeptAwakeResult

isKeptAwake()方法的结果

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

本页面由插件生成。 src/definitions.ts当公共API上游发生变化时,请重新同步。