File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 35
35
} ;
36
36
37
37
function getNetworkStatus ( ) {
38
+
39
+ // On Android and when only the 3G interface is on
40
+ // the return connection type is `unknown` even the device is online.
41
+ // To work around this we will assume that only Connection.NONE
42
+ // is declaring an offline device. Which is returned when data are
43
+ // disabled.
44
+
38
45
var isPluginAvailable = ! ! navigator . connection ;
39
46
40
47
if ( isPluginAvailable ) {
41
- return $cordovaNetwork . isOnline ( ) ;
48
+ var networkState = JSON . stringify ( navigator . connection ) ; //.type
49
+ console . log ( 'Internet connectivity chech. NetworkState: ' + networkState ) ;
50
+
51
+ // HACK: this is a temporary hack due to Android 3G related issue
52
+ // described above.
53
+ if ( navigator . connection . type . toLowerCase ( ) == 'unknown' ) {
54
+ return true ;
55
+ } else {
56
+ return $cordovaNetwork . isOnline ( ) ;
57
+ }
42
58
}
43
59
44
60
return navigator . onLine ;
45
61
}
46
62
} ) ;
47
63
} ) ;
48
- } ) ( ) ;
64
+ } ) ( ) ;
Original file line number Diff line number Diff line change 48
48
<feature name =" InAppBrowser" >
49
49
<param name =" ios-package" value =" CDVInAppBrowser" />
50
50
</feature >
51
+ <feature name =" NetworkStatus" >
52
+ <param name =" android-package" value =" org.apache.cordova.NetworkManager" />
53
+ </feature >
51
54
<preference name =" SplashScreen" value =" screen" />
52
55
<preference name =" SplashScreenDelay" value =" 3000" />
53
56
<preference name =" webviewbounce" value =" false" />
You can’t perform that action at this time.
0 commit comments