Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13730

cordova-plugin-network-information return wrong connection status on Android

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: cordova@7.1.0
    • Fix Version/s: None
    • Labels:
    • Environment:

      Windows 10, cordova-cli@7.1.0, cordova-android@6.4.0

    • Flags:
      Important

      Description

      There is a problem with cordova-plugin-network-information on Android. Even if there is internet connection, after the app is opened for a while, when I resume the app from the background and I check connection with navigator.connection.type, it returns connection.type = NONE: I tried to do an ajax request to verify the connection, and it works, so there is connection. If I close and re-open the app it returns connection.type = 4G. I use cordova@7.1.0 and cordova-android@6.4.0.
      My code to check the connection status is:

      function isOnline() {
          var networkState = navigator.connection.type;
          if (networkState !== Connection.NONE) {
              return true
          } else {
              return false
          }
      }
      

      Thanks
      Cristian

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ciossi Cristian Iossi
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: