Read the current device, OS, and locale snapshot
One.Device returns a snapshot of the device running your app: model,
operating system, form factor, simulator state, an app-scoped vendor id,
and the effective locale, languages, calendar, time zone, and currency.
It reads system APIs directly and never prompts for permission. For the
installed app’s own version, build, and bundle ID, use
One.AppInfo.
On iOS it reads UIDevice, Locale, and TimeZone. On Android it reads
Build, Settings.Secure, and the default locale and time zone. On web
the browser reports what it may: the platform string, Intl locale data,
and preferred languages, with hardware identity left blank.
import { One } from 'one'
const info = await One.Device.getInfo()console.log(info.model, info.systemName, info.systemVersion)
const locale = await One.Device.getLocalizationInfo()console.log(locale.localeIdentifier, locale.timeZoneIdentifier)Both calls are snapshots. For locale and calendar values that update with system changes, use Localization and its React hooks.
getInfo builds one object per call. On iOS the model is Apple’s device
family string such as iPhone, not a retail model name, and the vendor
identifier is identifierForVendor, which can be absent until after the
user first unlocks the device and can change once all of a vendor’s apps
are removed. On Android the model is Build.MODEL, the system name is
Android, the version is the release string, and the vendor identifier is
ANDROID_ID, scoped to the app signing key and never a hardware id. The
interface idiom is phone, pad, tv, carPlay, mac, vision, or unspecified;
Android reports tv for television, pad for smallest width 600dp and up,
and phone otherwise. isSimulator tells the iOS simulator or an Android
emulator apart from hardware.
getLocalizationInfo reads the effective locale as a BCP 47 tag, the
preferred language tags, the calendar identifier, the time zone
identifier, the current UTC offset in seconds (positive east of UTC,
reflecting daylight saving time at the moment of the call), and the
currency code when the platform exposes one. On web the locale,
calendar, and time zone come from Intl.DateTimeFormat, languages from
navigator.languages, and currency stays absent since browsers do not
expose the user’s chosen currency. Server rendering returns empty
strings, empty language lists, a zero offset, and no currency.
| Methods | Type | Description |
|---|---|---|
getInfo() => Promise<DeviceInfo>Model, OS, idiom, simulator flag, and vendor id. | () => Promise<DeviceInfo> | Model, OS, idiom, simulator flag, and vendor id. |
getLocalizationInfo() => Promise<LocalizationInfo>Locale, languages, calendar, time zone, and currency. | () => Promise<LocalizationInfo> | Locale, languages, calendar, time zone, and currency. |
| Device info | Type | Description |
|---|---|---|
modelstringDevice family on iOS, Build model on Android. | string | Device family on iOS, Build model on Android. |
systemNamestringThe OS name. | string | The OS name. |
systemVersionstringThe OS version string. | string | The OS version string. |
interfaceIdiomstringPhone, pad, tv, carPlay, mac, vision, or unspecified. | string | Phone, pad, tv, carPlay, mac, vision, or unspecified. |
isSimulatorbooleanSimulator or emulator rather than hardware. | boolean | Simulator or emulator rather than hardware. |
vendorIdentifierstringApp-scoped vendor id, when available. | string | App-scoped vendor id, when available. |
| Localization info | Type | Description |
|---|---|---|
localeIdentifierstringEffective locale as a BCP 47 tag. | string | Effective locale as a BCP 47 tag. |
preferredLanguagesstring[]Preferred language tags, best first. | string[] | Preferred language tags, best first. |
calendarIdentifierstringThe calendar identifier. | string | The calendar identifier. |
timeZoneIdentifierstringThe time zone identifier. | string | The time zone identifier. |
timeZoneOffsetSecondsnumberCurrent UTC offset, positive east. | number | Current UTC offset, positive east. |
currencyCodestringThe currency code, when exposed. | string | The currency code, when exposed. |
| iOS | Android | Web | |
|---|---|---|---|
| Model | Device family | Build model | Empty |
| Vendor id | Vendor scoped | App key scoped | Absent |
| Idiom | System idiom | Size based | Unspecified |
| Currency | When exposed | When exposed | Absent |
import { useEffect, useState } from 'react'import { One } from 'one'
function useIsPad() { const [isPad, setIsPad] = useState(false)
useEffect(() => { One.Device.getInfo().then((info) => { setIsPad(info.interfaceIdiom === 'pad') }) }, [])
return isPad}The idiom read happens once on mount, since the form factor cannot change under a running app. Phones and tablets then branch on one boolean.
import { useEffect, useState } from 'react'import { Text } from 'react-native'import { One } from 'one'
function LocalTime({ whenMs }: { whenMs: number }) { const [label, setLabel] = useState('')
useEffect(() => { One.Device.getLocalizationInfo().then((locale) => { setLabel( new Intl.DateTimeFormat(locale.localeIdentifier, { timeZone: locale.timeZoneIdentifier, hour: 'numeric', minute: '2-digit', }).format(new Date(whenMs)) ) }) }, [whenMs])
return <Text>{label}</Text>}Formatting with the reported locale and zone keeps times consistent with the rest of the device, including daylight saving time at the moment of the call.
Edit this page on GitHub.