Last active
December 18, 2015 08:26
-
-
Save skounis/d1391ca15fe852a39a4a to your computer and use it in GitHub Desktop.
Network check workaround for android due to issue https://issues.apache.org/jira/browse/CB-10160
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getNetworkStatus() { | |
| // On Android and when only the 3G interface is on | |
| // the return connection type is `unknown` even the device is online. | |
| // To work around this we will assume that only Connection.NONE | |
| // is declaring an offline device. Which is returned when data are | |
| // disabled. | |
| var isPluginAvailable = !!navigator.connection; | |
| if (isPluginAvailable) { | |
| var networkState = JSON.stringify(navigator.connection); //.type | |
| console.log('Internet connectivity chech. NetworkState: ' + networkState); | |
| // HACK: this is a temporary hack due to Android 3G related issue | |
| // described above. | |
| if (navigator.connection.type.toLowerCase() == 'unknown'){ | |
| return true; | |
| }else { | |
| return $cordovaNetwork.isOnline(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment