Kadir Damene
Kadir Damene

Reputation: 358

How can I determine whether a device supports 4G?

Depending on the network connectivity I would like to show varying content, so I would like to determine whether a device supports 4G or 3G connectivity. How can I do this? I tried looking for a solution, but haven't been able to find anything.

Upvotes: 0

Views: 38

Answers (1)

SANGEETH KUMAR S G
SANGEETH KUMAR S G

Reputation: 598

You can use cordova-plugin-network-information plugin to check the current network state of the user

 $ionicPlatform.ready(function() {
        var networkState = $cordovaNetwork.getNetwork();
        console.log('network state: ',networkState);
        if (networkState == Connection.CELL_4G) {
           //show the contents to the user while user is in 4g
        }else{
           //show the contents to the user if not 4g
        }
    })

The available values of the network state are

  • Connection.WIFI
  • Connection.CELL_2G
  • Connection.CELL_3G
  • Connection.CELL_4G
  • Connection.NONE
  • Connection.CELL
  • Connection.UNKNOWN
  • Connection.ETHERNET

Upvotes: 1

Related Questions