Get Current Network Environment
methodName: getNetworkType
Additional Parameters:
None
Success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
networkType | String | Current network environment |
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure |
Explanation of networkType
Values
networkType Value | Description |
---|---|
wifi | Wi-Fi network |
2g | 2G network |
3g | 3G network |
4g | 4G network |
5g | 5G network |
unknown | Uncommon network types on Android |
none | No network |
Fail Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure |
errMsg | String | Error message |
Example Usage
const dlt = window['@transsion/byteh5bridge'];
const canCallDlt = dlt && window.dltms && window.dltms.isMiniShellGame();
if (canCallDlt) {
dlt.callApi('getNetworkType', {
success: (res) => {
console.log('Success: ', res);
},
fail: (res) => {
console.log('Fail: ', res);
},
complete: (res) => {
console.log('Complete: ', res);
},
});
}