开始使用
复制一个包含安装步骤和此插件的完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-barometer`
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/barometer/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.
安装
标题:安装您可以使用我们的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-barometer` plugin in my project.如果您更喜欢手动设置,请使用以下命令安装插件,并按照以下平台特定的说明进行操作:
bun add @capgo/capacitor-barometerbunx cap sync导入
标题:导入import { CapacitorBarometer } from '@capgo/capacitor-barometer';API 介绍
标题:API 介绍getMeasurement
标题:getMeasurement获取本地层捕获的最新气压计读数。
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.getMeasurement();isAvailable
标题:isAvailable检查当前设备是否具有气压计传感器。
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.isAvailable();startMeasurementUpdates
标题:startMeasurementUpdates开始将气压计更新流式传输到 JavaScript 层。
使用 measurement 接收更新事件。
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.startMeasurementUpdates();stopMeasurementUpdates
标题:停止测量更新停止通过 . 开始的连续更新。
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.stopMeasurementUpdates();checkPermissions
标题:检查权限返回当前访问计量数据的权限状态。
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.checkPermissions();requestPermissions
标题:请求权限请求访问计量数据的权限,如果平台要求的话。
import { CapacitorBarometer } from '@capgo/capacitor-barometer';
await CapacitorBarometer.requestPermissions();类型参考
类型参考GetMeasurementResult
获取测量结果最新压力样本的别名。
export type GetMeasurementResult = Measurement;IsAvailableResult
可用性结果方法返回的结果
export interface IsAvailableResult { /** * Indicates whether the device exposes a barometer sensor. * * @since 1.0.0 */ isAvailable: boolean;}PermissionStatus
权限状态方法和返回的权限信息
export interface PermissionStatus { /** * The permission state for accessing barometer measurements on the current platform. * * @since 1.0.0 */ barometer: BarometerPermissionState;}MeasurementEvent
测量事件事件在压力采集器激活时发射的载荷
export type MeasurementEvent = Measurement;Measurement
标题:测量设备加速度计采样到的空气压力和相对海拔值。
export interface Measurement { /** * The static air pressure in hectopascals (hPa). * * @since 1.0.0 */ pressure: number;
/** * The change in altitude relative to the time updates started. * Only available on iOS; Android will always return `0`. * * @since 1.0.0 */ relativeAltitude: number;
/** * The timestamp of the measurement in milliseconds since the Unix epoch. * * @since 1.0.0 */ timestamp: number;}BarometerPermissionState
标题:BarometerPermissionState包括对于可以限制传感器访问的平台的权限状态。 limited 复制到剪贴板
export type BarometerPermissionState = PermissionState | 'limited';PermissionState
支持__CAPGO_KEEP_0__的平台权限状态。Platform permission states supported by Capacitor.
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';protectedTokens
源头真相该页面由插件生成 src/definitions.ts.重新同步公共API时,API上游发生变化
继续从开始
继续从开始如果您正在使用 开始 计划仪表板和API操作 Using @capgo/capacitor-barometer 使用@capgo/capacitor-barometer 使用@API/__CAPGO_KEEP_1__-barometer API概述 简介 了解简介的实现细节 API 键 了解API 键的实现细节 设备 了解设备的实现细节