Starting from version 1078, the API prefix has been changed from hbs to qg. The original prefix hbs is still supported.
API | Description |
|---|---|
Obtains the network type. | |
Listens for the network status change event. | |
Stops listening for the network status change event. |
Parameter | Type | Mandatory | Description |
|---|---|---|---|
success | function | No | Callback function triggered upon a successful API call. For details, please refer to Parameters in the success callback function. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | If a function is passed, it will be called regardless of whether the API call succeeds or fails. |
Parameter | Type | Description |
|---|---|---|
networkType | string | Network type. For details, please refer to Valid values of networkType. |
qg.getNetworkType({
success : function (res) {
console.log("getNetworkType success networkType" + res.networkType );
},
fail:function(){
console.log("getNetworkType fail");
},
complete:function() {
console.log("getNetworkType complete");
}
}); Parameter | Type | Mandatory | Description |
|---|---|---|---|
callback | function | Yes | Callback function triggered when a network status change event occurs. For details, please refer to Parameters in callback. |
Parameter | Type | Description |
|---|---|---|
isConnected | boolean | Indicates whether there is a network connection. |
networkType | string | Network type. For details, please refer to Valid values of networkType. |
qg.onNetworkStatusChange(
function callback(res){
console.log("onNetworkStatusChange isConnected = " + res.isConnected + ", networkType = " + res.networkType);
}
);