Types
All types are exported from the package root:
import type {
BatteryState,
DeviceDetails,
DeviceType,
ListenerSubscription,
PowerState,
} from 'nitro-device-info'
DeviceDetails
Device and app values that stay the same while the app runs, returned by getDeviceDetails(). Optional fields are absent on one platform; Platform differences lists the source of each.
| Field | Type | Description |
|---|---|---|
brand | string | The consumer brand: Apple on iOS, Build.BRAND on Android, for example google. |
manufacturer | string | Apple on iOS, Build.MANUFACTURER on Android, for example Google. |
model | string | UIDevice.model on iOS (iPhone, iPad), Build.MODEL on Android (Pixel 9). |
modelName | string | The marketing name, for example iPhone 16 Pro. Falls back to model for iOS models the table does not know. |
deviceId | string | The hardware identifier: machine name on iOS (iPhone17,3), Build.DEVICE on Android (tokay). |
productName | string, optional | Build.PRODUCT, for example tokay. Absent on iOS. |
deviceName | string | The name the user gave the device. The generic model on iOS 16+ without the entitlement. |
deviceType | DeviceType | The kind of device. |
deviceYearClass | number, optional | The release year of a flagship with similar performance. Absent for iOS models the table does not know. |
supportedAbis | string[] | The CPU architectures the device runs, most preferred first, for example arm64-v8a. |
systemName | string | iOS or iPadOS on iOS, Android on Android. |
systemVersion | string | The OS version, for example 27.2 or 16. |
osBuildId | string | The kernel's OS version on iOS (24A335), Build.DISPLAY on Android. |
osBuildFingerprint | string, optional | Build.FINGERPRINT. Absent on iOS. |
apiLevel | number, optional | Build.VERSION.SDK_INT. Absent on iOS. |
appName | string | The app's display name. |
bundleId | string | The bundle identifier on iOS, the application ID on Android. |
appVersion | string | CFBundleShortVersionString on iOS, versionName on Android. |
buildNumber | string | CFBundleVersion on iOS, versionCode on Android. |
installerPackageName | string, optional | The store that installed the app, for example com.android.vending. Absent on iOS and when sideloaded. |
isEmulator | boolean | Whether the app runs on the iOS simulator or an Android emulator. The Android check is a heuristic. |
isRooted | boolean | Whether the device looks jailbroken or rooted. A heuristic; always false on simulators and emulators. |
hasNotch | boolean | Whether the screen has a notch or another cutout. A Dynamic Island does not count. false before Android API 29. |
hasDynamicIsland | boolean | Whether the screen has a Dynamic Island. Always false on Android. |
totalMemory | number | The device's physical memory in bytes. |
maxMemory | number, optional | The Java heap limit in bytes (Runtime.maxMemory). Absent on iOS. |
PowerState
The battery and power-saving state, returned by getPowerState() and passed to power state listeners.
| Field | Type | Description |
|---|---|---|
batteryLevel | number, optional | Charge from 0 to 1, or undefined when the platform cannot tell, as on the iOS simulator. |
batteryState | BatteryState | Whether the battery is charging. |
lowPowerMode | boolean | Whether Low Power Mode on iOS or Battery Saver on Android is on. |
BatteryState
type BatteryState = 'unknown' | 'unplugged' | 'charging' | 'full'
| Value | Meaning |
|---|---|
unknown | The platform cannot tell, as on the iOS simulator. |
unplugged | Running on battery. |
charging | Plugged in and charging. |
full | Plugged in with a full battery. |
DeviceType
type DeviceType = 'phone' | 'tablet' | 'tv' | 'desktop' | 'unknown'
| Value | Meaning |
|---|---|
phone | A phone. |
tablet | A tablet: an iPad, or an Android device at least 600 dp wide. |
tv | A TV. |
desktop | An iPhone or iPad app running on a Mac, or an Android device in desktop mode. |
unknown | A device the platform does not classify, such as Apple Vision Pro. |
ListenerSubscription
interface ListenerSubscription {
remove: () => void
}
A registered listener, returned by addOnPowerStateChangedListener. Call remove() to stop receiving events; calling it again does nothing.