my.onNetworkStatusChange
Use this JSAPI to listen to the event of network status change. After the interface is called, listening is automatically started. The callback interval is 500ms. You can use my.offNetworkStatusChange to stop listening.
Sample Code
Page({
// callback function
listener(res) {
console.log(res);
},
// listen to the event of network status change
onNetworkStatusChange() {
my.onNetworkStatusChange(this.listener);
},
});
Parameters
Property | Type | Required | Description |
listener | Function | Yes | The callback function to listen to the event of network status change. |
listener
Callback Function
The incoming parameter is of the Object type with the following attributes:
Property | Type | Description |
isConnected | Boolean | Indicates whether the network is connected. |
networkType | String | Indicates the network type. Valid value:
|
signalStrength | Number | Indicates the signal strength in "dbm" unit. This parameter is used only when the Note: This parameter is returned only for Android. |
hasSystemProxy | Boolean | Indicates whether using the network proxy. |