跳过内容

入门

GitHub

您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

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

如果您更喜欢手动设置,请通过运行以下命令安装插件并按照以下平台特定的说明进行操作:

终端窗口
bun add @capgo/capacitor-proximity
bunx cap sync
import { CapacitorProximity } from '@capgo/capacitor-proximity';

开启近距离监控.

在 iOS 上,这会启用 UIDevice.isProximityMonitoringEnabled. 在 Android 上,这会开始监听 TYPE_PROXIMITY 并在传感器被遮盖时降低当前 应用程序窗口的亮度.

import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.enable();

关闭近距离监控.

这会恢复默认的应用程序窗口行为并停止传感器监控.

import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.disable();

获取当前传感器可用性和插件启用状态.

import { CapacitorProximity } from '@capgo/capacitor-proximity';
const status = await CapacitorProximity.getStatus();

类型参考

类型参考部分

Section titled “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';
}

Result returned when requesting the plugin version.

export interface PluginVersionResult {
/**
* Native plugin version string.
*
* @since 0.0.1
*/
version: string;
}

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

继续从 Getting Started

标题:继续从 Getting Started

如果您正在使用 Getting Started 来规划仪表板和 API 操作,连接它到 使用 @capgo/capacitor-proximity 对于在使用 @capgo/capacitor-proximity 中的原生能力 API Overview 对于在 API Overview 中的实现细节 Introduction 对于在 Introduction 中的实现细节 API Keys 为API Keys的实现细节,和 设备 为设备的实现细节,