开始使用
复制一个包含安装步骤和本插件完整Markdown指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-proximity`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/proximity/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
安装bun add @capgo/capacitor-proximitybunx cap sync导入
导入import { CapacitorProximity } from '@capgo/capacitor-proximity';API概述
API概述enable
启用启用附近监测。
在iOS上启用 UIDevice.isProximityMonitoringEnabled.
在 Android 上,这会开始监听 TYPE_PROXIMITY 并在传感器被遮盖时降低当前
应用程序窗口的亮度。
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.enable();disable
标题为“disable”禁用近距离监控.
这会恢复默认的应用程序窗口行为并停止传感器监控.
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.disable();getStatus
标题为“getStatus”获取当前传感器可用性和插件启用状态.
import { CapacitorProximity } from '@capgo/capacitor-proximity';
const status = await CapacitorProximity.getStatus();ProximityStatusResult
“ProximityStatusResult”标题请求时返回的结果 getStatus().
export interface ProximityStatusResult { /** * Whether the current device exposes a usable proximity sensor. * * @since 0.0.1 */ available: boolean;
/** * Whether proximity monitoring is currently enabled by the plugin. * * @since 0.0.1 */ enabled: boolean;
/** * Platform label returned by the native or web implementation. * * @since 0.0.1 */ platform: 'ios' | 'android' | 'web';}PluginVersionResult
“PluginVersionResult”标题请求插件版本时返回的结果
export interface PluginVersionResult { /** * Native plugin version string. * * @since 0.0.1 */ version: string;}真实数据来源
“真实数据来源”标题本页由插件生成。 当公共__CAPGO_KEEP_0__上游更改时,请重新运行同步。 src/definitions.ts. Re-run the sync when the public API changes upstream.