This API is used via wx.onNetworkStatusChange(function callback).
Attribute | Type | Description |
isConnected | boolean | Current Network Connection Status |
networkType | string | Network type |
Value | Description |
wifi | Wi-Fi Network |
2g | 2G Network |
3g | 3G Network |
4g | 4G Network |
unknown | Uncommon Network Types on Android |
none | No network |
wx.onNetworkStatusChange(function (res) {console.log(res.isConnected)console.log(res.networkType)})
This API is used via wx.getNetworkType(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
networkType | string | Network type |
Value | Description |
wifi | Wi-Fi Network |
2g | 2G Network |
3g | 3G Network |
4g | 4G Network |
unknown | Uncommon Network Types on Android |
none | No network |
wx.getNetworkType({success(res) {const networkType = res.networkType}})
This API is used via wx.offNetworkStatusChange(function listener).
const listener = function (res) { console.log(res) }wx.onNetworkStatusChange(listener)wx.offNetworkStatusChange(listener) // The same function object as the listener must be passed in.
Was this page helpful?