@capgo/capacitor-proximity

June 16, 2026 ยท View on GitHub

Capgo - Instant updates for Capacitor

โžก๏ธ Get Instant updates for your App with Capgo

Missing a feature? We'll build the plugin for you ๐Ÿ’ช

Capacitor plugin for enabling proximity monitoring in mobile apps.

Why this plugin

This plugin wraps the native proximity APIs used by iOS and Android so a Capacitor app can:

  • Enable proximity monitoring when a screen should react to the user's face or hand.
  • Disable it cleanly when the flow ends.
  • Check whether the current device supports the sensor.
  • Read the plugin version from native code.

On iOS, the plugin forwards directly to UIDevice.isProximityMonitoringEnabled. On Android, it listens to the device proximity sensor and dims the active app window while the sensor is covered.

Platform support

PlatformSupport
iOSโœ… Uses native proximity monitoring
Androidโœ… Uses Sensor.TYPE_PROXIMITY and dims the current app window
WebโŒ Not available

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8..v8..โœ…
v7..v7..On demand
v6..v6..โŒ
v5..v5..โŒ

The plugin major version follows the Capacitor major version.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

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

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

bun add @capgo/capacitor-proximity
bunx cap sync

Usage

import { CapacitorProximity } from '@capgo/capacitor-proximity';

const status = await CapacitorProximity.getStatus();

if (status.available) {
  await CapacitorProximity.enable();

  // ...run your near-ear or face-down flow...

  await CapacitorProximity.disable();
}

Notes

  • Test on a real device. Simulators and most desktop browsers do not expose a proximity sensor.
  • On Android, the plugin only affects the current app window. It does not control the full system display outside your app.
  • On iOS, Apple controls the exact screen-off behavior once proximity monitoring is enabled.

Example app

The example-app/ folder contains a small Vite demo for checking status, enabling the plugin, disabling it, and reading the native version.

API

Capacitor plugin for enabling proximity monitoring in mobile apps.

enable()

enable() => Promise<void>

Enable proximity monitoring.

On iOS this enables UIDevice.isProximityMonitoringEnabled. On Android this starts listening to TYPE_PROXIMITY and dims the current app window while the sensor is covered.

Since: 0.0.1


disable()

disable() => Promise<void>

Disable proximity monitoring.

This restores the default app window behavior and stops sensor monitoring.

Since: 0.0.1


getStatus()

getStatus() => Promise<ProximityStatusResult>

Get the current sensor availability and plugin enabled state.

Returns: Promise<ProximityStatusResult>

Since: 0.0.1


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Get the current native plugin version.

Returns: Promise<PluginVersionResult>

Since: 0.0.1


Interfaces

ProximityStatusResult

Result returned by getStatus().

PropTypeDescriptionSince
availablebooleanWhether the current device exposes a usable proximity sensor.0.0.1
enabledbooleanWhether proximity monitoring is currently enabled by the plugin.0.0.1
platform'ios' | 'android' | 'web'Platform label returned by the native or web implementation.0.0.1

PluginVersionResult

Result returned when requesting the plugin version.

PropTypeDescriptionSince
versionstringNative plugin version string.0.0.1