跳过内容

开始使用

GitHub

您可以使用我们的 AI 助手设置来安装插件。使用以下命令将 Capgo 技能添加到您的 AI 工具中:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-android-kiosk` plugin in my project.

如果您更喜欢手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:

终端窗口
bun add @capgo/capacitor-android-kiosk
bunx cap sync

导入

导入
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';

API概述

API概述

isInKioskMode

__CAPGO_KEEP_1__

检查应用是否处于全屏模式。

import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
const { isInKioskMode } = await CapacitorAndroidKiosk.isInKioskMode();
console.log('Kiosk mode active:', isInKioskMode);

isSetAsLauncher

__CAPGO_KEEP_2__

检查应用是否设置为设备启动器(主应用)。

import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
const { isLauncher } = await CapacitorAndroidKiosk.isSetAsLauncher();
console.log('Is launcher:', isLauncher);

进入全屏模式,隐藏系统UI并阻止硬件按钮。 此模式下,应用程序必须设置为设备启动器,才能有效工作。 此功能也会启动一个前台保活服务,减少系统杀死应用程序的可能性。

import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.enterKioskMode();

退出全屏模式,恢复正常的系统UI和硬件按钮功能。 此功能也会停止前台保活服务,启动在进入全屏模式时启动的服务。

import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.exitKioskMode();
console.log('Exited kiosk mode');

打开设备的主屏幕设置,允许用户将此应用程序设置为启动器。 此功能是全屏模式功能的必要条件。

import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
await CapacitorAndroidKiosk.setAsLauncher();
// User will be prompted to select this app as the home app

设置在全屏模式下允许功能的硬件键。 在全屏模式下,所有硬件键默认被阻止。

import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';
// Allow volume keys only
await CapacitorAndroidKiosk.setAllowedKeys({
volumeUp: true,
volumeDown: true,
back: false,
home: false,
recent: false
});

类型参考

类型参考

EnterKioskModeOptions

进入全屏模式选项

全屏模式下的可选标志 enterKioskMode.

export interface EnterKioskModeOptions {
/**
* After reboot, start the app so you can call `enterKioskMode()` again. Best-effort only (OEM
* behavior, force-stop). Omit to keep the saved value. Cleared when you call `exitKioskMode()`.
*/
restoreAfterReboot?: boolean;
/**
* Periodically tries to bring the app to the foreground. Skipped while the screen is off. Often
* blocked from the background on some devices—being the default launcher, relaxing battery limits,
* and allowing exact alarms (where required) improve odds. Omit to keep the saved value.
*/
relaunch?: boolean;
/** Minutes between relaunch attempts when `relaunch` is on. Range 5–60; default 15. */
relaunchIntervalMinutes?: number;
}

复制到剪贴板

export interface AllowedKeysOptions {
/**
* Allow volume up button
* @default false
*/
volumeUp?: boolean;
/**
* Allow volume down button
* @default false
*/
volumeDown?: boolean;
/**
* Allow back button
* @default false
*/
back?: boolean;
/**
* Allow home button
* @default false
*/
home?: boolean;
/**
* Allow recent apps button
* @default false
*/
recent?: boolean;
/**
* Allow power button
* @default false
*/
power?: boolean;
/**
* Allow camera button (if present)
* @default false
*/
camera?: boolean;
/**
* Allow menu button (if present)
* @default false
*/
menu?: boolean;
}

重新同步公共__CAPGO_KEEP_0__时请重新运行 src/definitions.ts重新同步公共API时请重新运行

继续从 Getting Started

标题:继续从 Getting Started

如果您正在使用 Getting Started 来规划仪表板和 API 操作,连接它与 使用 @capgo/capacitor-android-kiosk 为 native 能力在使用 @capgo/capacitor-android-kiosk 中 API 概述 为 API 概述 的实现细节 介绍 为介绍 的实现细节 API 密钥 为API Keys的实现细节,和 设备 为设备的实现细节,