Device APIs

getNetworkType

Get the network type.

Overview

my.getNetworkType retrieves the current network type of the device, such as WiFi, 2G, 3G, 4G, or offline status.

Sample Code

my.getNetworkType({
  success: (res) => {
    console.log(res.networkAvailable);
    console.log(res.networkType);
  },
});

Parameters

PropertyTypeRequiredDescription
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

PropertyTypeDescription
networkAvailableBooleanWhether the network is available.
networkTypeStringNetwork type values:
WIFI: WiFi network
2G: 2G network
3G: 3G network
4G: 4G network
UNKNOWN: Unknown network
NOTREACHABLE: No network
NONE: None

Usage Notes

  • Returns current network connectivity status
  • Useful for optimizing data usage based on connection type
  • Can detect when device is offline
  • Network type helps determine appropriate content quality and caching strategies