Taro.getSystemInfo(res)
Gets system information. Support for Promise based use.
Type
(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
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
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.getSystemInfo | ✔️ | ✔️ | ✔️ |