Expo 常量
提供在应用安装的整个生命周期中保持不变的系统信息的 API。
expo-constants 提供在应用安装的整个生命周期内保持不变的系统信息。
¥expo-constants provides system information that remains constant throughout the lifetime of your app's installation.
安装
¥Installation
- npx expo install expo-constantsIf you are installing this in an existing React Native app, make sure to install expo in your project.
API
import Constants from 'expo-constants';
Types
Type: Record<string, any> extended by:
| Property | Type | Description |
|---|---|---|
| versionCode | number |
The version code set by |
Type: ManifestsEASConfig
Type: ManifestsExpoGoConfig
Type: Record<string, any> extended by:
| Property | Type | Description |
|---|---|---|
| buildNumber | string | null | The build number specified in the embedded Info.plist value for |
| model | string | null |
The human-readable model name of this device. For example, |
| platform | string |
The Apple internal model identifier for this device. Example
|
| systemVersion | string |
The version of iOS running on this device. Example
|
| userInterfaceIdiom | UserInterfaceIdiom |
The user interface idiom of the current device, such as whether the app is running on an iPhone, iPad, Mac or Apple TV. |
Type: ExpoUpdatesManifest
Type: ManifestAssetForReExport
Type: ManifestExtraForReExport
Type: Record<string, any> extended by:
| Property | Type | Description |
|---|---|---|
| appOwnership | AppOwnership | null |
Returns |
| debugMode | boolean | Returns |
| deviceName(optional) | string | A human-readable name for the device type. |
| deviceYearClass | number | null |
The device year class of this device. |
| easConfig | ManifestsEASConfig | null | The standard EAS config object populated when using EAS. |
| executionEnvironment | ExecutionEnvironment | Returns the current execution environment. |
| experienceUrl | string | - |
| expoConfig | ExpoConfig & {
hostUri: string
} | null | The standard Expo config object defined in app.json and app.config.js files. For both classic and modern manifests, whether they are embedded or remote. |
| expoGoConfig | ManifestsExpoGoConfig | null | The standard Expo Go config object populated when running in Expo Go. |
| expoRuntimeVersion | string | null | Nullable only on the web. |
| expoVersion | string | null | The version string of the Expo Go app currently running.
Returns |
| getWebViewUserAgentAsync | () => Promise<string | null> | Gets the user agent string which would be included in requests sent by a web view running on
this device. This is probably not the same user agent you might be providing in your JS |
| intentUri(optional) | string | - |
| isDetached(optional) | boolean | - |
| isHeadless | boolean | Returns |
| linkingUri | string | - |
| manifest2 | ExpoUpdatesManifest | null | Manifest for Expo apps using modern Expo Updates from a remote source, such as apps that
use EAS Update. |
| platform(optional) | PlatformManifest | Returns the specific platform manifest object.
|
| sessionId | string | A string that is unique to the current session of your app. It is different across apps and across multiple launches of the same app. |
| statusBarHeight | number | The default status bar height for the device. Does not factor in changes when location tracking is in use or a phone call is active. |
| systemFonts | string[] | A list of the system font names available on the current device. |
| systemVersion(optional) | number | - |
Type: Record<string, any> extended by:
| Property | Type | Description |
|---|---|---|
| android(optional) | AndroidManifest | - |
| detach(optional) | {
scheme: string
} | - |
| developer(optional) | string | - |
| hostUri(optional) | string | - |
| ios(optional) | IOSManifest | - |
| scheme(optional) | string | - |
| web(optional) | WebManifest | - |
Enums
Deprecated Use
Constants.executionEnvironmentinstead.
AppOwnership.Expo = "expo"The experience is running inside the Expo Go app.
Current supported values are handset, tablet, desktop and tv. CarPlay will show up
as unsupported.