Check network connectivity

4 posts, 0 answers
  1. Chris
    Chris avatar
    14 posts
    Member since:
    Oct 2012

    Posted 25 Mar 2013 Link to this post

    Hi I'm just doing some research. Is it possible to detect if the app is connected to the internet and what type of connection it specifically is it wifi? Cheers, Chris.
  2. Jordan
    Admin
    Jordan avatar
    197 posts

    Posted 26 Mar 2013 Link to this post

    Hi Chris,

    Check this Cordova API for Connection in Documentation to get the connection type.

    And to detect when your application switch between online and offline state hook up to the corresponding events (see Cordova Events Documentation).

    Greetings,
    Jordan
    the Telerik team

    Share feedback and vote for features on our Feedback Portal.
    Want some Kendo UI online training - head over to Pluralsight.
  3. Markus
    Markus avatar
    205 posts
    Member since:
    Nov 2005

    Posted 29 Aug 2013 Link to this post

    Better late then never. Code might help someone.

    Markus

    app.checkConnection = function()
      {
          var networkState = navigator.connection.type;
     
          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';
     
          $('#sp_connection_type').text(states[networkState] + " " + device_language);
          if (states[networkState] == 'No network connection') {
                         navigator.notification.alert(
              'No active connection found!',
              oppenSettings,
              'Network ',
             'OK'
              );
               
          }
      }
     
        // I wanted a confirm button first opening setting,
         // but not available now
      function oppenSettings(buttonIndex) {
      if (buttonIndex == 1) {
        // alert("we do something");
      }
      else {
      // alert('we do nothing! ');
      }
  4. jaweria
    jaweria avatar
    3 posts
    Member since:
    Mar 2016

    Posted 18 May Link to this post

    can we use Broadcast receiver in ionic framework?

    i want to show toast when network is connected.. is it possible in ionic framework

Back to Top