Passer au contenu

Getting Started

Ce contenu n'est pas encore disponible dans votre langue.

Terminal window
bun add @capgo/capacitor-android-kiosk
bunx cap sync
import { CapacitorAndroidKiosk } from '@capgo/capacitor-android-kiosk';

Checks if the app is currently running in kiosk mode.

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

Checks if the app is set as the device launcher (home app).

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

Enters kiosk mode, hiding system UI and blocking hardware buttons. Also starts a foreground keep-alive service so the app is less likely to be killed by the system. The app must be set as the device launcher for this to work effectively.

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

Exits kiosk mode, restoring normal system UI and hardware button functionality. Also stops the foreground keep-alive service started in enterKioskMode().

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

Opens the device’s home screen settings to allow user to set this app as the launcher. This is required for full kiosk mode functionality.

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

Sets which hardware keys are allowed to function in kiosk mode. By default, all hardware keys are blocked in kiosk mode.

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

Optional flags for 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;
}

Configuration options for allowed hardware keys in kiosk mode.

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;
}

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.