コンテンツにジャンプ

はじめに

ターミナルウィンドウ
bun add @capgo/capacitor-keep-awake
bunx cap sync
import { KeepAwake } from '@capgo/capacitor-keep-awake';

画面の暗幕を防止します。

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

画面の暗幕を許可します (keep awake を無効)。

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

__CAPGO_KEEP_0__の機能が現在のプラットフォームでサポートされているかどうかを確認します。

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

isKeptAwake

isKeptAwake

__CAPGO_KEEP_2__が現在実行されているかどうかを確認します。

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

Type Reference

__CAPGO_KEEP_4__

IsSupportedResult

IsSupportedResult

isSupported()メソッドの結果です。

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

IsKeptAwakeResult

Type Reference

__CAPGO_KEEP_6__の結果です。

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

このページはプラグインの src/definitions.ts公開 API がアップストリームで変更された場合に再度同期を実行してください。