@capgo/capacitor-proximity
v8.1.2
Published
Capacitor plugin for enabling proximity monitoring in mobile apps.
Maintainers
Readme
@capgo/capacitor-proximity
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
| Platform | Support |
|----------|---------|
| iOS | ✅ Uses native proximity monitoring |
| Android | ✅ Uses Sensor.TYPE_PROXIMITY and dims the current app window |
| Web | ❌ Not available |
Compatibility
| Plugin version | Capacitor compatibility | Maintained | | -------------- | ----------------------- | ---------- | | v8.. | v8.. | ✅ | | v7.. | v7.. | On demand | | v6.. | v6.. | ❌ | | v5.. | v5.. | ❌ |
The plugin major version follows the Capacitor major version.
Install
bun add @capgo/capacitor-proximity
bunx cap syncUsage
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().
| Prop | Type | Description | Since |
| --------------- | ---------------------------------------- | ---------------------------------------------------------------- | ----- |
| available | boolean | Whether the current device exposes a usable proximity sensor. | 0.0.1 |
| enabled | boolean | Whether 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.
| Prop | Type | Description | Since |
| ------------- | ------------------- | ----------------------------- | ----- |
| version | string | Native plugin version string. | 0.0.1 |
