capacitor-barometer
v1.0.1
Published
Capacitor-Barometer is a native plugin for Capacitor that provides access to barometric pressure sensor data on supported devices. Easily integrate real-time atmospheric pressure readings into your cross-platform mobile apps for weather tracking, altitude
Maintainers
Readme
capacitor-barometer
Capacitor-Barometer is a native plugin for Capacitor that provides access to barometric pressure sensor data on supported devices. Easily integrate real-time atmospheric pressure readings into your cross-platform mobile apps for weather tracking, altitude estimation, or scientific applications.
Install
npm install capacitor-barometer
npx cap syncAPI
isAvailable()start()stop()getPressure()echo(...)addListener('onPressureChange', ...)removeAllListeners()- Interfaces
isAvailable()
isAvailable() => Promise<{ available: boolean; }>Checks if the barometer sensor is available on the device.
Returns: Promise<{ available: boolean; }>
start()
start() => Promise<void>Starts listening for barometer updates. This will also trigger the 'onPressureChange' event.
stop()
stop() => Promise<void>Stops listening for barometer updates.
getPressure()
getPressure() => Promise<{ pressure: number; }>Gets the last known pressure reading. Ensure 'start()' has been called and data is available.
Returns: Promise<{ pressure: number; }>
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>An echo method for testing.
| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
addListener('onPressureChange', ...)
addListener(eventName: 'onPressureChange', listenerFunc: (data: { pressure: number; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandleCalled when pressure data changes.
| Param | Type | Description |
| ------------------ | ----------------------------------------------------- | ------------------------------------------ |
| eventName | 'onPressureChange' | The name of the event ('onPressureChange') |
| listenerFunc | (data: { pressure: number; }) => void | The callback function to be executed. |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners()
removeAllListeners() => Promise<void>Removes all listeners for this plugin.
Interfaces
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
