Skip to main content
Version: 3.x

Taro.getSystemInfo(res)

Gets system information. Support for Promise based use.

Reference

Type

(res?: Option) => Promise<Result>

Parameters

Option

PropertyTypeRequiredDescription
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

Result

NOTE: Version, statusBarHeight, fontSizeSetting, SDKVersion are not supported on the H5.

PropertyTypeDescription
SDKVersionstringClient base library version
albumAuthorizedbooleanThe switch that allows WeChat to use Photos (only for iOS)
benchmarkLevelnumberThe device performance grade (only for Mini Games on Android). Values: -2 or 0 (the device cannot run the Mini Game), -1 (unknown performance), ≥1 (a higher value (up to 50) indicates a better performance).
bluetoothEnabledbooleanThe system switch for Bluetooth
brandstringDevice brand
cameraAuthorizedbooleanThe switch that allows WeChat to use the camera
fontSizeSettingnumberUser's font size in px. The setting in Me > Settings > General > Text Size in the WeChat app prevails.
languagestringLanguage set in WeChat
locationAuthorizedbooleanThe switch that allows WeChat to use the location function
locationEnabledbooleanThe system switch for the GPS function
microphoneAuthorizedbooleanThe switch that allows WeChat to use the microphone
modelstringDevice model
notificationAlertAuthorizedbooleanThe switch that allows WeChat to send notifications with reminders (only for iOS)
notificationAuthorizedbooleanThe switch that allows WeChat to send notifications
notificationBadgeAuthorizedbooleanThe switch that allows WeChat to send notifications with flags (only for iOS)
notificationSoundAuthorizedbooleanThe switch that allows WeChat to send notifications with sound (only for iOS).
pixelRationumberDevice's pixel ratio
platformstringClient platform
safeAreaSafeAreaResultSafe area when the screen is in vertical orientation
screenHeightnumberScreen height in px
screenWidthnumberScreen width in px
statusBarHeightnumberStatus bar height in px
systemstringOperating system and version
versionstringWeChat version
wifiEnabledbooleanThe system switch for Wi-Fi
windowHeightnumberAvailable window height in px
windowWidthnumberAvailable window width in px
errMsgstringCall results

Sample Code

Example code 1

Taro.getSystemInfo({
success: res => console.log(res)
})
.then(res => console.log(res))

Example code 2

Taro.getSystemInfo({
success: function (res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
}
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.getSystemInfo✔️✔️✔️