Installed-binary identity, read synchronously
One.AppInfo is the installed binary’s identity: the user-visible
marketing version, the binary build string, and the install id. Read it
to show a version row in settings, to tag error reports, or to compare
the running binary against a minimum build. For the device and OS around
the app, see One.Device.
On iOS the fields come from the bundle (CFBundleShortVersionString,
CFBundleVersion, CFBundleIdentifier). On Android they come from the
package (versionName, versionCode, applicationId). On web there is
no installed binary: the version comes from the ONE_APP_VERSION
build-time value, and build and install id are always null.
import { Text } from 'react-native'import { One } from 'one'
function VersionRow() { return ( <Text> {One.AppInfo.version} ({One.AppInfo.build}) </Text> )}The read is synchronous and frozen at import. The binary cannot change under a running process, so the values never go stale.
The snapshot is read once at import from the OneAppInfo hybrid object
and frozen. On native it always describes the installed binary, never
bundle-time values: after an over-the-air update the JavaScript bundle
and the binary disagree, which is exactly when a build comparison must
read the binary. A binary without the module, such as an old build,
yields nulls rather than guesses. The build is stringified on both
platforms so display and comparison code stays platform-blind.
Prebuild stamps the binary values from native.app: version becomes
the marketing version and versionName, ios.buildNumber becomes the
current project version, and android.versionCode becomes the version
code. Missing fields keep the template defaults, so a store build must
set all three.
| Fields | Type | Description |
|---|---|---|
versionstring | nullMarketing version. Null when unknown. | string | null | Marketing version. Null when unknown. |
buildstring | nullBinary build, stringified. Null when unknown. | string | null | Binary build, stringified. Null when unknown. |
applicationIdstring | nullBundle id on iOS, application id on Android. | string | null | Bundle id on iOS, application id on Android. |
| iOS | Android | Web | |
|---|---|---|---|
| Version | Bundle short version | Package version name | Build-time value |
| Build | Bundle version | Version code, as text | Always null |
| Install id | Bundle id | Application id | Always null |
import { Text } from 'react-native'import { One } from 'one'
function SettingsVersion() { const { version, build, applicationId } = One.AppInfo if (!version) return null return ( <Text> {version} ({build}) {applicationId} </Text> )}Destructuring once keeps the render free of repeated member reads. A null version hides the row instead of showing a guessed one.
import { One } from 'one'
function needsUpdate(minBuild: number) { const build = Number(One.AppInfo.build) if (!Number.isFinite(build)) return false return build < minBuild}Builds compare numerically since both platforms stringify the same value. An unknown build refuses to nag, which is safer than blocking a user on missing data.
Edit this page on GitHub.