All Products
Search
Document Center

SuperApp:Network status

Last Updated:Oct 25, 2024

This topic describes the JavaScript API of WVNetwork. You can refer to this topic when you create HTML5 apps or Miniapps. You can use the JavaScript API of WVNetwork to obtain the current network type.

WVNetwork.getNetworkType

Obtains the current network type.

Input parameters

  • [boolean]wifiStatus: specifies whether to obtain the Wi-Fi information. This parameter is valid only when your device is connected to a Wi-Fi network and WindVane 8.2.0 or later is used. When the Wi-Fi information is requested, ssid and bssid are returned.

  • [boolean]wifiList: specifies whether to obtain the list of available Wi-Fi networks. When the Wi-Fi list is requested, wifiList is returned. This parameter is valid when WindVane 8.2.0 or later is used on Android.

Callback parameters

Callback parameters are passed by using the callback method. This API operation always invokes the success callback.

  • [string]type: the current network type. Valid values:

    • 'NONE': indicates that no networks are available.

    • 'WIFI': indicates that the device is connected to a Wi-Fi network.

    • 'CELL': indicates that the device is connected to a cellular network. It can be a 2G, 3G, or 4G network.

    • '2G': indicates that the device is connected to a 2G network.

    • '3G': indicates that the device is connected to a 3G network.

    • '4G': indicates that the device is connected to a 4G network.

    • 'UNKNOWN': indicates that the network type cannot be identified.

  • [string]message: the specific network connection type. The operating system may fail to identify the network connection type.

  • [string]ssid: the service set identifier (SSID) of the Wi-Fi network. This parameter is available in WindVane 8.2.0 or later.

  • [string]bssid: the basic service set identifier (BSSID) of the Wi-Fi network. This parameter is available in WindVane 8.2.0 or later.

  • [Array]wifiList: the list of available Wi-Fi networks. This parameter is available in WindVane Android 8.2.0 or later. This parameter is not supported in iOS. The parameter value is an array of objects with the following attributes.

  • [string]ssid: the service set identifier (SSID) of the Wi-Fi network.

  • [string]bssid: the basic service set identifier (BSSID) of the Wi-Fi network.

window.WindVane.call('WVNetwork', 'getNetworkType', {}, function(e) {
        alert(JSON.stringify(e));
});