Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches: [master, main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm test

example-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: |
package-lock.json
example/package-lock.json
- run: npm ci
- run: npm run build
- name: Install example app
working-directory: example
run: npm ci
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ node_modules/
npm-debug.log
yarn-error.log

# Build output
lib/

# Xcode
#
build/
Expand Down Expand Up @@ -46,5 +49,6 @@ example/node_modules/
example/ios/Pods/
example/ios/build/
example/android/build/
example/android/app/build/
example/android/.gradle/
example/vendor/
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog

## 2.1.0

### Enhancements
- Soft-fail when the Turbo Module is missing (`isSupported()` → `false`, `watch()` → `-1`) instead of crashing AppRegistry
- Surface native sensor failures via `onBarometerError` / the optional `watch` error callback
- Add `useBarometer()` React hook with automatic subscribe/cleanup
- Add `setSmoothing(alpha)` for configurable EMA filtering
- Add `setAltitudeReference(metres)` to calibrate local pressure from a known altitude
- Add `resetRelativeAltitude()`
- Export `getAltitude` / `pressureFromAltitude` helpers
- Include `accuracy` on the payload (Android sensor accuracy; `-1` on iOS)
- Monotonic watch IDs (no sparse-array holes)
- TypeScript source compiled to `lib/` with package `exports`
- Restore in-repo example app (RN 0.86, New Architecture)
- GitHub Actions CI (typecheck + unit tests + example install)
- Widen peer dependency to `react-native >= 0.84` (no upper bound)

### Docs
- README updated for the new API, Expo notes, background behavior, and migration
- Added `CHANGELOG.md` and `MIGRATION.md`

## 2.0.0

- New Architecture only (Turbo Modules)
- Kotlin Android module and Obj-C++ iOS module
- Shared JS validation helpers and unit tests
36 changes: 36 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Migrating to v2 / v2.1

## Legacy bridge apps (RN 0.59–0.83)

Stay on **v1.x**. v2+ requires the **New Architecture** (Turbo Modules) and does not load on the legacy bridge.

## v1 → v2.0

1. Enable New Architecture in your app (RN 0.84+ recommended).
2. Upgrade to `react-native-barometer@2`.
3. Rebuild native apps (`pod install`, clean Android build).
4. Keep calling `isSupported()` before `watch()` — some devices and simulators have no barometer.

### Breaking changes in v2.0
- Legacy bridge is not supported
- Peer range targets modern RN + React 19

## v2.0 → v2.1

Mostly additive. Recommended updates:

```diff
- import Barometer from 'react-native-barometer';
+ import Barometer, {useBarometer} from 'react-native-barometer';

const id = Barometer.watch(payload => {
console.log(payload.pressure);
- });
+ }, error => {
+ console.warn(error.code, error.message);
+ });
```

- `BarometerPayload` now includes `accuracy` (number; `-1` when unknown)
- Import paths resolve through `exports` → `lib/`; no code change needed for default imports
- If you previously relied on a hard crash when the native module was missing, handle `isSupported() === false` or `watch() === -1` instead
Loading
Loading