# The concept of system information

uni-app provides two asynchronous (uni.getSystemInfo) and synchronous (uni.getSystemInfoSync) APIs to obtain system information.

System information returns a lot of content, and each operating system, each MiniApp, and each browser have different definitions of them. These concepts are reorganized in uni-app, and the original concepts of these platforms are also retained for backward compatibility, but it is not recommended to use.

Sorted according to the level of the operating environment, from the bottom up, uni-app has 6 concepts:

  • device:运行应用的设备,如iphone、huawei
  • os:设备的操作系统,如 ios、android、windows、mac、linux
  • rom: customization based on the operating system, unique concepts of the Android system, such as miui, Hongmeng
  • host: The host program that runs the application, that is, the operating environment between the OS and the application, such as the browser, WeChat and other MiniApp hosts, and the App integrated with uniMPSDK. The app directly developed by uni-app has no host concept
  • uni: Information related to the uni-app framework, such as the compiler version and runtime version of the uni-app framework
  • app: developer's application-related information, such as application name, version

# uni.getSystemInfo(OBJECT)

Get system information asynchronously

OBJECT parameter description:

Parameter Name Type Required Description
success Function Yes the callback of successful interface call
fail Function No Callback function for interface call failure
complete Function No The callback function for the end of the interface call (it will be executed when the call succeeds or fails)

# success return parameter description

Parameter classification Parameter Description App platform value range Web platform value range MiniApp platform value range Remarks Minimum version requirements of the uni framework
device deviceId The device id. Generated and stored by the uni-app framework, clearing Storage will cause changes
deviceType The device type. Such as phone, pad, pc, unknow see phone, pad, pc, unknow phone, pad, pc uni-app 3.4.10+
deviceBrand Device brand. Such as: apple, huawei Not supported uni-app 3.4.10+
deviceModel Device model Some devices cannot be obtained uni-app 3.4.10+
deviceOrientation Device orientation vertical portrait, horizontal landscape vertical portrait, horizontal landscape vertical portrait, horizontal landscape. Only supported by WeChat and Baidu MiniApp uni-app 3.4.13+
devicePixelRatio device pixel ratio uni-app 3.4.13+
os osName 系统名称 ios、android ios、android、windows、macos、linux ios、android、windows、macos uni-app 3.4.10+
osVersion 操作系统版本。如 ios 版本,android 版本 uni-app 3.4.10+
osLanguage Operating system languageSee details Consistent with the browser language Not supported uni-app 3.4.10+
osTheme OS theme light, dark. The iOS platform can only get the theme of the system when the theme of the application is set to follow the system Not supported Not supported uni-app 3.4.10+
osAndroidAPILevel Android system API library version. For details, refer to Android Official Documentation Only supported by Android Not supported Not supported uni-app 3.4.10+
rom romName rom name The value cannot be obtained for some Android models, see details. iOS not supported not supported not supported uni-app 3.4.13+
romVersion rom version The value cannot be obtained for some Android models, see details. iOS not supported not supported not supported uni-app 3.4.13+
browser browserName Browser name or App webview name chrome (android), wkwebview (ios), x5webview (app packaging x5 engine) chrome, edge, safari, firefox not supported uni-app 3.4.10 +
browserVersion Browser version, webview version Not supported uni-app 3.4.10+
host hostName The integrated host name of the MiniApp host or uniMPSDK, such as: WeChat, `MiniApp Only supported by UniMPSDK Not supported See details value uni-app 3.4.10+
hostVersion Host version. Such as: WeChat version number Only supported by UniMPSDK Not supported MiniApp host version uni-app 3.4.10+
hostLanguage Host language Only supported by UniMPSDK Not supported MiniApp host language uni-app 3.4.10+
hostTheme 宿主主题 lightdark。仅 UniMPSDK 支持 不支持 lightdark。前提是微信小程序全局配置"darkmode":true时才能获取 uni-app 3.4.10+
hostFontSizeSetting 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px 不支持 不支持 微信小程序、支付宝小程序、百度小程序、QQ小程序、抖音小程序(2.53.0+) uni-app 3.4.13+
hostPackageName MiniApp host package name Only supported by UniMPSDK Not supported Not supported uni-app 3.4.10+
hostSDKVersion uni MiniApp SDK version, MiniApp client base library version only supported by UniMPSDK not supported uni-app 3.4.13+
uni-app framework uniPlatform The running platform of uni-app is the same as the conditional compilation platform. See details app web or h5 various MiniApp, such as mp-weixin uni-app 3.4.10+
uniCompileVersion uni Compiler version number. See 3.4.10, 3.2.9, etc. 3.4.10, 3.2.9, etc. 3.4.10, 3.2.9, etc. uni -app 3.4.10+
uniRuntimeVersion uni runtime version. See 3.4.10, 3.2.9, etc. 3.4.10, 3.2.9, etc. 3.4.10, 3.2.9, etc. uni -app 3.4.10+
app appId manifest 中应用appid,即DCloud appid。 uni-app 3.4.10+
appName manifest 中应用名称 抖音小程序字段冲突,抖音小程序原字段与hostName一致 uni-app 3.4.10+
appVersion The app version name in manifest. uni-app 3.4.10+
appVersionCode The application version name in manifest. uni-app 3.4.10+
appWgtVersion Version name of the application resource (wgt). uni-app 3.4.15+
appLanguage Language set by the application en, zh-Hans, zh-Hant, fr, es en, zh-Hans, zh-Hant, fr, es en, zh-Hans, zh-Hant, fr, es uni-app 3.4.13+
Others ua userAgent ID Not Supported uni-app 3.4.10+
screenWidth screen width
screenHeight screen height
windowWidth Available window width
windowHeight Available window height
windowTop The top position of the available window
windowBottom The bottom position of the available window
statusBarHeight 手机状态栏的高度
safeArea 在竖屏正方向下的安全区域。由于此属性理解和使用比较困难,更推荐使用 safeAreaInsets 属性。详见 微信、百度(开发者工具暂不支持,真机有效)、抖音、飞书、支付宝(iOS真机)、快手、QQ小程序、华为快应用
safeAreaInsets 在竖屏正方向下的安全区域插入位置。与小程序定义的 safeArea 用途相同,但是规范参考 iOS 平台的 safeAreaInsets 更利于理解和使用。详见 微信、百度(开发者工具暂不支持,真机有效)、抖音、飞书、支付宝小程序(iOS真机)、华为快应用 uni-app 2.5.3+

# Special return parameters for some applets

Parameter Description Platform Difference Description
benchmarkLevel Device performance level. Values: -2 or 0 (the device cannot run mini games), -1 (the performance is unknown), >=1 (the device performance value, the higher the value, the better the device performance, currently the highest is less than 50) WeChat MiniApp Android Version, QQ MiniApp Android Version
batteryLevel Remaining battery percentage (only valid for iOS) WeChat MiniApp
currentBattery Current battery percentage Alipay MiniApp
navigationBarHeight The height of the navigation bar Baidu MiniApp
titleBarHeight Title Bar Height Alipay MiniApp
albumAuthorized Switch to allow WeChat to use albums (only valid for iOS) WeChat MiniApp
cameraAuthorized Allow WeChat to use the camera switch WeChat MiniApp
locationAuthorized Allow WeChat to use location switch WeChat MiniApp
microphoneAuthorized The switch that allows WeChat to use the microphone WeChat MiniApp
notificationAuthorized Allow WeChat notification switch WeChat MiniApp
notificationAlertAuthorized Allow WeChat notification with reminder switch (only valid for iOS) WeChat MiniApp
notificationBadgeAuthorized Allow WeChat notifications to be marked with a switch (only valid for iOS) WeChat MiniApp
notificationSoundAuthorized Allow WeChat notification with sound switch (only valid for iOS) WeChat MiniApp
bluetoothEnabled Bluetooth system switch WeChat MiniApp
locationEnabled System switch of geographic location WeChat MiniApp
wifiEnabled Wi-Fi system switch WeChat MiniApp
cacheLocation Last cached location information Baidu MiniApp(minimum base library version 3.40.4 for Android; minimum supported version 3.70.2 for iOS)
storage Device Disk Capacity Alipay MiniApp

# Deprecated return parameters, reserved only for backward compatibility

Parameter Description Platform Difference Description
pixelRatio 设备像素比
brand 设备品牌。uni-app 3.4.10+ 后该字段为全小写,可能要做兼容处理 App、微信小程序、百度小程序、抖音小程序、飞书小程序、QQ小程序
model Device model All platforms are supported. Specific models cannot be obtained for some devices on the web
system OS name and version, such as Android 10
language language set by the application
version Engine version number Web does not support
platform client platform, the value range is: ios, android, mac(3.1.10+), windows(3.1.10+), linux(3.1.10+)
host hosting platform Baidu MiniApp
SDKVersion Client basic library version Alipay MiniApp and Web do not support
swanNativeVersion host platform version number Baidu MiniApp
app Currently running client Alipay MiniApp
AppPlatform App平台 QQ小程序
fontSizeSetting 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px 微信小程序、支付宝小程序、百度小程序、QQ小程序、抖音小程序(2.53.0+)

# uniPlatform return value description

value valid condition
app App
web Web
mp-weixin WeChat MiniApp
mp-alipay Alipay MiniApp
mp-baidu 百度小程序
mp-toutiao 抖音小程序
mp-lark Feishu MiniApp
mp-qq QQ MiniApp
mp-kuaishou Kuaishou MiniApp
mp-jd JD MiniApp
mp-360 360 MiniApp
quickapp-webview QuickApp general (including Alliance, Huawei)
quickapp-webview-union QuickApp Union
quickapp-webview-huawei QuickApp Huawei

uniCompileVersion compiler version and uniRuntimeVersion runtime version, under normal circumstances should be the same value, that is, the version of uni-app.

If you use the uni-app that comes with HBuilder to develop, this value is equivalent to the version of HBuilder; if you use the separate uni-app cli to develop, it is equivalent to the cli version.

But on the App platform, the values of uniCompileVersion and uniRuntimeVersion will be different in some cases:

  • App cloud packaging chooses a packager version that does not match. For example, the HBuilder version is old and there is no corresponding packager in the cloud. At this time, uniCompileVersion will be smaller than uniRuntimeVersion after packaging.
  • The app is packaged offline, using a mismatched offline SDK
  • App wgt upgrade, that is, the app installed on the mobile phone is the old version uniRuntimeVersion, the new version of wgt uses a different version of HBuilder or uni-app cli version, and implements the application resource upgrade

# romName Return value description

value interpretation
MIUI Xiaomi
EMUI Huawei
HarmonyOS Huawei Hongmeng
ColorOS oppo
Funtouch OS vivo
FLymeOS Meizu
SmartisanOS Hammer

Note: The version number rules of different roms are different, for example, the version number of MIUI is V130, and the version number of HarmonyOS is 2.0.0

# hostName return value description

value interpretation
WeChat WeChat
wxwork WeChat Enterprise Edition
Baidu host platform enumeration value list Baidu
alipay Alipay
amap Gold
DINGTALK DingTalk
UC UC Browser
QUARK Quark Browser
AK Ali Health
YK 优酷
qq QQ
KUAISHOU Kuaishou

# safeArea return value description

Parameter Type Description
left Number Abscissa of the upper left corner of the safe area
right Number Abscissa of the lower right corner of the safe area
top Number The ordinate of the upper left corner of the safe area
bottom Number The vertical coordinate of the lower right corner of the safe area
width Number The width of the safe area, in logical pixels
height Number The height of the safe area, in logical pixels

Structure of safeAreaInsets

Parameter Type Description
left Number Insert position on the left side of the safe area
right Number Insert position on the right side of the safe area
top Number Insert position at the top of the safe area
bottom Number Insert position at the bottom of the safe area

# language return value description

The international specification of language is BCP47 specification, which is divided into three sections, main language-secondary language-region. For example zh-Hans-CN means Chinese-Simplified-Mainland China

But except for the main language, the latter two can be omitted. On different platforms, their omission rules are also different.

  • app-ios, not omitted, returns zh-Hans-CN
  • app-android, web, WeChat MiniApp, omit sub-language, return zh-CN
  • The uni-app framework and multilingual applications, as well as the Alipay MiniApp, use zh-Hans to represent Simplified Chinese

Therefore, after obtaining the language, strings cannot be compared directly, and segments need to be compared. There is also a library on npm dedicated to comparing BCP47 language specification.

# deviceId return value description

Web, MiniApp, and iOS are all platforms that strictly protect user privacy, and it is difficult to obtain effective unique device tags on these platforms.

Android has also improved user privacy protection. On very old mobile phones, you can obtain unlimited imei. On second-old mobile phones, when obtaining private information such as imei, you need to pop up a box to ask the user to authorize. New Android phones (Android10 and above) have been completely unable to obtain imei.

Therefore, most of the marking devices can only be marked by storing a random number locally.

deviceId, on the app-android platform, will use imei and mac according to the priority (only if the user has authorized, if it is found that authorization or unauthorized, skip this step), if not obtained, it will be randomly generated logo. Other platforms use randomly generated logos directly.

When using random numbers stored locally, the deviceId will become invalid in the following situations:

  • Uninstall apps
  • Reset App data on Android
  • The browser clears the cache or turns on the privacy mode,

For scenarios that require ad tracking under the app, idfa can be used on iOS, and [OAID](http://www. html5plus.org/doc/zh_cn/device.html#plus.device.getOAID)

# deviceModel return value description

The uni-app 3.5.1+ version standardizes the return value of deviceModel. For example, the return value of iPhone11ProMax in the new version is iPhone 11 Pro Max. Each device model [reference specification](https://www.theiphonewiki.com/ wiki/Models) corresponding to the value of Generation

Note: Unknown will be displayed for a while after the new model is launched, and the official will adapt it as soon as possible.

# Other notes

  • deviceType
    • app-ios only supports phone, pad.

    • app-android supports phone, pad, tv, car, watch, vr, appliance, undefined, unknown, more detailed explanations about each type Refer to Android Official Documentation.

    • Among them, the judgment of pad type under the app-android platform is not necessarily accurate on non-Google official devices such as domestic pads. If necessary, the developer can make a judgment based on the model or screen size. The Java code for judging pad in the uni-app framework source code is as follows, for reference:

      public static boolean isTablet(Context context) {
      	return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
      }
      
  • osTheme: app-ios Only when the application theme is set to follow the system can the theme of the system be obtained. MiniApp have similar restrictions.
  • Screen height = native NavigationBar height (including status bar height) + usable window height + native TabBar height
  • windowHeight does not contain the height of NavigationBar and TabBar
  • On the Web side, windowTop is equal to the height of NavigationBar, and windowBottom is equal to the height of TabBar
  • On the App side, windowTop is equal to the height of the NavigationBar in the transparent state, and windowBottom is equal to the height of the TabBar in the transparent state
  • Highly relevant information should be obtained in onReady. Too early to get it.

Links to the documentation of this API in other MiniApp:

# Example

Call code example

uni.getSystemInfo({
	success: function (res) {
		console.log(res.appName)
	}
});

The return value of getSystemInfo on different platforms (the table is long, you can drag the horizontal scroll bar after zooming the page)

Those marked with - are undefined, other values are the same as the listed items

Field Name App-Android App-iOS h5 Android uniMPsdk iOS uniMPsdk mp-weixin mp-alipay mp-baidu mp-toutiao
appId __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001 __UNI__8BB4001
appName test test test test test test test test test
appVersion 1.0.0 1.0.0 1.0.0 1.0.0 1.0.0 1.0.0 1.0.0 1.0.0 1.0.0
appVersionCode 100 100 100 100 100 100 100 100 100
appLanguage zh-Hans zh-Hans zh-Hans zh-Hans zh-Hans zh-Hans zh-Hans zh-Hans zh-Hans
browserName chrome wkwebview safari chrome wkwebview - - - -
browserVersion 96.0.4664.104 13.4.13 13.0.3 88.0.4324.93 15.4 - - - -
deviceId d3db0944da20f333 F791564F-853B-47B6-8CB8-27FF59315059 16518284854447835016 c7eafa7ed8774c0d F791564F-853B-47B6-8CB8-27FF59315059 1652178285720384773 16536215804846585135 1653359639811213582 16538995501084056633
deviceBrand xiaomi apple - huawei apple iphone iphone iphone apple
deviceModel Mi10Pro iPhone13ProMax iPhone MXW-AN00 iPhoneSimulator iPhone6/7/8Plus iPhone14,3 iPhone6/7/8 iPhone6
deviceType phone phone phone phone phone phone phone phone phone
deviceOrientation portrait portrait portrait portrait portrait portrait - portrait -
devicePixelRatio 2.5687501430511475 3 2 3 3 3 3 2 2
hostVersion - - 13.0.3 1.0 1.0.0 8.0.5 10.2.23 2.45.0 6.6.3
hostLanguage - - zh-CN zh-CN zh-Hans-CN zh-CN zh-CN zh-CN
hostTheme - - - light light - - - -
hostPackageName - - - com.example.mplauncherv3 io.dcloud.hellounimp - - - -
hostSDKVersion - - - 3.4.13 3.4.13 2.24.2 2.7.6 3.450.16 2.49.0
osName android ios ios android ios ios ios ios ios
osVersion 12 15.5 13.2.3 10 15.4 10.0.1 15.5 15.5 10.0.1
osLanguage zh-CN zh-Hans-CN - zh-CN zh-Hans-CN - - - -
osTheme light light - light light - - - -
osAndroidAPILevel 31 - - 29 - - - - - -
romName MIUI - - HarmonyOS - - - - -
romVersion V130 - - 2.0.0 - - - - -
uniPlatform app app web app app mp-weixin mp-alipay mp-baidu mp-toutiao
uniCompileVersion 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13
uniRuntimeVersion 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13 3.4.13

# uni.getSystemInfoSync()

A synchronous interface for obtaining system information. The call parameters and return value are the same as above getSystemInfo.

The content of device information is numerous and complex. Developers are welcome to test more environmental devices and edit this document to contribute.