Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API power


May 19, 2021 WeChat Mini Program Development Document


Table of contents


Object wx.getBatteryInfoSync()

A synchronized version of wx.getBatteryInfo

Returns a value

Object res

Property Type Description
level string Device power, range 1 - 100
isCharging boolean Whether charging is in

wx.getBatteryInfo(Object object)

Get the device's power. Sync API wx.getBatteryInfoSync is not available on iOS.

Parameters

Object object

Property Type The default Required Description
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)

object.success callback function

Parameters
Object res
Property Type Description
level string Device power, range 1 - 100
isCharging boolean Whether charging is in