Parameters
| Property | Type | Required | Description |
|---|---|---|---|
| success | Function | No | Callback with network type |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
Success Callback
| Property | Type | Description |
|---|---|---|
| networkType | String | Network type: UNKNOWN, NOTREACHABLE, WWAN, WIFI, 2G, 3G, 4G, 5G |
| networkAvailable | Boolean | Whether network is available |
| signalStrength | Number | Signal strength in dbm. Only used when networkType is WIFI. Android only |
| hasSystemProxy | Boolean | Whether the network proxy is being used |
Code Example
my.getNetworkType({
success: (res) => {
console.log('Network:', res.networkType);
if (!res.networkAvailable) {
my.showToast({ content: 'No network', type: 'fail' });
}
}
});