@nadlowebagentur/capacitor-device-control
v0.1.1
Published
Device control helpers for Capacitor (wake, open app, sleep, admin/notifications checks)
Readme
capacitor-device-control
Android-first device control helpers for Capacitor (wake, open app, sleep, admin checks).
iOS and web implementations are stubs for now.
Install
npm install @nadlowebagentur/capacitor-device-control
npx cap syncAPI
wakeUp(...)openApp(...)sleep()isAdminActive()requestAdmin(...)ensureAdmin(...)isScreenOn()activateKnoxLicense(...)isKnoxAvailable()openAccessibilitySettingsPage()openDeviceAdminSettingsPage()addListener('screenStateChanged', ...)removeAllListeners()- Interfaces
wakeUp(...)
wakeUp(options?: WakeOptions | undefined) => Promise<void>| Param | Type |
| ------------- | --------------------------------------------------- |
| options | WakeOptions |
openApp(...)
openApp(options?: OpenAppOptions | undefined) => Promise<void>| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | OpenAppOptions |
sleep()
sleep() => Promise<SleepResult>Returns: Promise<SleepResult>
isAdminActive()
isAdminActive() => Promise<AdminStatus>Returns: Promise<AdminStatus>
requestAdmin(...)
requestAdmin(options?: AdminPromptOptions | undefined) => Promise<AdminStatus>| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | AdminPromptOptions |
Returns: Promise<AdminStatus>
ensureAdmin(...)
ensureAdmin(options?: AdminPromptOptions | undefined) => Promise<AdminStatus>| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | AdminPromptOptions |
Returns: Promise<AdminStatus>
isScreenOn()
isScreenOn() => Promise<ScreenState>Returns: Promise<ScreenState>
activateKnoxLicense(...)
activateKnoxLicense(options: KnoxActivateOptions) => Promise<KnoxActivateResult>Activate a Samsung Knox KPE license. Samsung devices only — call once at app start.
| Param | Type |
| ------------- | ------------------------------------------------------------------- |
| options | KnoxActivateOptions |
Returns: Promise<KnoxActivateResult>
isKnoxAvailable()
isKnoxAvailable() => Promise<KnoxAvailability>Reports whether the Knox SDK is present on the current device.
Returns: Promise<KnoxAvailability>
openAccessibilitySettingsPage()
openAccessibilitySettingsPage() => Promise<void>Opens the system Accessibility Settings screen (legacy permission path).
openDeviceAdminSettingsPage()
openDeviceAdminSettingsPage() => Promise<void>Opens the system Device Admin screen for this app (activate, or review/deactivate when already active).
addListener('screenStateChanged', ...)
addListener(eventName: 'screenStateChanged', listener: (state: ScreenState) => void) => Promise<PluginListenerHandle>| Param | Type |
| --------------- | ----------------------------------------------------------------------- |
| eventName | 'screenStateChanged' |
| listener | (state: ScreenState) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Interfaces
WakeOptions
| Prop | Type |
| ------------------ | -------------------- |
| reason | string |
| bringToFront | boolean |
OpenAppOptions
| Prop | Type |
| ------------ | ------------------- |
| reason | string |
SleepResult
| Prop | Type | Description |
| ------------- | -------------------- | -------------------------------------------------------------------------------------------------------- |
| success | boolean | |
| reason | string | One of: 'device_admin' | 'accessibility' | 'service_not_enabled' | 'not_supported' | 'action_failed' |
AdminStatus
| Prop | Type | Description |
| ------------------- | -------------------- | ---------------------------------------------------------------------------------------- |
| active | boolean | True if at least one lock-capable permission (device admin OR accessibility) is granted. |
| deviceAdmin | boolean | True if the app is registered as a Device Administrator. |
| accessibility | boolean | True if the legacy Accessibility Service is enabled. |
AdminPromptOptions
| Prop | Type |
| ----------------- | -------------------- |
| enabled | boolean |
| title | string |
| message | string |
| actionLabel | string |
| cancelLabel | string |
ScreenState
| Prop | Type |
| ---------------- | -------------------- |
| isScreenOn | boolean |
KnoxActivateResult
| Prop | Type |
| --------------- | -------------------- |
| success | boolean |
| errorCode | number |
KnoxActivateOptions
| Prop | Type | Description |
| ---------------- | ------------------- | -------------------------------------------------- |
| licenseKey | string | KPE license key obtained from Samsung Knox portal. |
KnoxAvailability
| Prop | Type |
| --------------- | -------------------- |
| available | boolean |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
