Example app
example/ is a NitroUI app that shows every value the package reads, on one scrolling screen:
- every
DeviceDetailsfield, read once withuseState(() => DeviceInfo.getDeviceDetails()); - the power state, kept current with
addOnPowerStateChangedListenerin an effect; - used memory, font scale, vendor ID, headphones and passcode, re-read by a Refresh button;
- whether location is enabled and the user agent, resolved from their promises.
Run it
From the repo root:
bun install # links the workspace, generates bindings and prepares the example
bun run example ios # or: bun run example android
Native harness tests
The tests in example/__tests__ use nitro-ui-harness and run inside the example app on a simulator, emulator or device:
bun run test:ios --device "<simulator name or UDID>"
bun run test:android --device <adb-serial>
| File | Covers |
|---|---|
DeviceInfo.harness.ts | Both platforms: details, caching, power, listener removal, memory, font scale, vendor ID, user agent, location. |
DeviceInfo.ios.harness.ts | iOS only. |
DeviceInfo.android.harness.ts | Android only. |
CI builds the example and runs these tests on an iOS simulator and an Android emulator.