You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/06 13:22:18 UTC

[GitHub] hriziya commented on issue #80: Error: Connection is not defined

hriziya commented on issue #80: Error: Connection is not defined
URL: https://github.com/apache/cordova-plugin-network-information/issues/80#issuecomment-444868673
 
 
   My code is the function to `checkConnection()`
   ```
   function checkConnection() {
       if (navigator
          && navigator.connection
          && navigator.connection.type) {
   
           var networkState = navigator.connection.type;
   
           if(typeof(Connection) != 'undefined')
           {
               var states = {};
               states[Connection.UNKNOWN] = 'Unknown connection';
               states[Connection.ETHERNET] = 'Ethernet connection';
               states[Connection.WIFI] = 'WiFi connection';
               states[Connection.CELL_2G] = 'Cell 2G connection';
               states[Connection.CELL_3G] = 'Cell 3G connection';
               states[Connection.CELL_4G] = 'Cell 4G connection';
               states[Connection.CELL] = 'Cell generic connection';
               states[Connection.NONE] = 'No network connection';
   
               if (networkState == Connection.NONE) {
                   showMessage(states[networkState], function () {
                       hideLoading();
                       return false;
                   });
               }
               return networkState !== Connection.NONE;
           }
       }
   
       return true;
   }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org