title: Taro.getSystemInfo(res)

sidebar_label: getSystemInfo

Gets system information. Support for Promise based use.

Reference

Type

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

Parameters

Option

Property Type Required Description
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

Result

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

Property Type Description
SDKVersion string Client base library version
albumAuthorized boolean The switch that allows WeChat to use Photos (only for iOS)
benchmarkLevel number The 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).
bluetoothEnabled boolean The system switch for Bluetooth
brand string Device brand
cameraAuthorized boolean The switch that allows WeChat to use the camera
fontSizeSetting number User’s font size in px. The setting in Me > Settings > General > Text Size in the WeChat app prevails.
language string Language set in WeChat
locationAuthorized boolean The switch that allows WeChat to use the location function
locationEnabled boolean The system switch for the GPS function
microphoneAuthorized boolean The switch that allows WeChat to use the microphone
model string Device model
notificationAlertAuthorized boolean The switch that allows WeChat to send notifications with reminders (only for iOS)
notificationAuthorized boolean The switch that allows WeChat to send notifications
notificationBadgeAuthorized boolean The switch that allows WeChat to send notifications with flags (only for iOS)
notificationSoundAuthorized boolean The switch that allows WeChat to send notifications with sound (only for iOS).
pixelRatio number Device’s pixel ratio
platform string Client platform
safeArea SafeAreaResult Safe area when the screen is in vertical orientation
screenHeight number Screen height in px
screenWidth number Screen width in px
statusBarHeight number Status bar height in px
system string Operating system and version
version string WeChat version
wifiEnabled boolean The system switch for Wi-Fi
windowHeight number Available window height in px
windowWidth number Available window width in px
errMsg string Call results

Sample Code

Example code 1

  1. Taro.getSystemInfo({
  2. success: res => console.log(res)
  3. })
  4. .then(res => console.log(res))

Example code 2

  1. Taro.getSystemInfo({
  2. success: function (res) {
  3. console.log(res.model)
  4. console.log(res.pixelRatio)
  5. console.log(res.windowWidth)
  6. console.log(res.windowHeight)
  7. console.log(res.language)
  8. console.log(res.version)
  9. console.log(res.platform)
  10. }
  11. })

API Support

API WeChat Mini-Program H5 React Native
Taro.getSystemInfo ✔️ ✔️ ✔️