Skip to main content
Get information about the current network connection.

Parameters

PropertyTypeRequiredDescription
successFunctionNoCallback with network type
failFunctionNoCallback on failure
completeFunctionNoCallback that always executes

Success Callback

PropertyTypeDescription
networkTypeStringNetwork type: WIFI, 2G, 3G, 4G, 5G, UNKNOWN, NONE
networkAvailableBooleanWhether network is available

Code Example

my.getNetworkType({
  success: (res) => {
    console.log('Network:', res.networkType);
    if (!res.networkAvailable) {
      my.showToast({ content: 'No network', type: 'fail' });
    }
  }
});