HomeDocs
Skip to main content

Get Current Network Environment

methodName: getNetworkType

Additional Parameters:

None

Success Callback Function

Parameters

Object res

PropertyTypeDescription
networkTypeStringCurrent network environment
successStringDescribes whether the interface call was successful or not. "true" for success, "false" for failure

Explanation of networkType Values

networkType ValueDescription
wifiWi-Fi network
2g2G network
3g3G network
4g4G network
5g5G network
unknownUncommon network types on Android
noneNo network

Fail Callback Function

Parameters

Object res

PropertyTypeDescription
successStringDescribes whether the interface call was successful or not. "true" for success, "false" for failure
errMsgStringError 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);
},
});
}
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.