Comments (9)
Try this if you're using phonegap:
phonegap plugin remove cordova-plugin-network-information
phonegap plugin add cordova-plugin-network-information
phonegap build android
Or this if you're using cordova without phonegap(untested):
cordova plugin remove cordova-plugin-network-information
cordova plugin add cordova-plugin-network-information
cordova build android
Longer explanation probably worth reading:
For background, I generated the hello world template from phonegap and had this problem on multiple versions of phonegap, trying fresh projects and an old project. I noticed in platforms/android/platform_www/plugins
there was nothing referencing cordova-plugin-network-information
or even just "network". I saw other plugins listed here such as camera, battery-status, etc but nothing for network which made me think this is an issue building android and its not including the plugin at all. I deleted my android build and built it again with --verbose and noticed there was an error that happened - Failed to install 'cordova-plugin-camera': CordovaError: Uh oh!
. Instead of cordova/phonegap failing, or bringing this to the front of my attention, it just continues on its way, builds the android app and says it was successful at the bottom of the output (but really it should fail if its missing a plugin).
After I manually reinstalled the plugin (and one more I needed) via the commands above, I now see platforms/android/platform_www/plugins/cordova-plugin-network-information
and all is well. Not quite sure who to "blame the finger" at since this is all extremely developer unfriendly, but this is not this plugins fault for sure.
from cordova-plugin-network-information.
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;
}
from cordova-plugin-network-information.
Hola, tengo un problema con las conexiones a Internet, uso el plugin Network de ionic y el problema que tengo es, cuando el tipo de conexión cambia de wifi a datos y la aplicación está en segundo plano el tipo de conexión que recibe es NONE, tengo que matar la aplicación y volver a iniciarla para que ya todo vaya correctamente, alguien ha experimentado este problema?
from cordova-plugin-network-information.
Closing due to staleness.
My best advice with the information available is to ensure that you're code is only accessing these properties after the deviceready has fired.
If the issue persists, don't hesitate to open a new issue with the issue form filled out.
from cordova-plugin-network-information.
What is your actual code? Or is it just the one line you posted?
from cordova-plugin-network-information.
navigate is undefined
from cordova-plugin-network-information.
are you waiting for device ready event before calling the plugin code?
from cordova-plugin-network-information.
@elbartostrikesagain Worked for me! thanks!
from cordova-plugin-network-information.
@elbartostrikesagain cordova plugin add cordova-plugin-network-information
was the fix for me, I suspect that it was installed non globally, then another project spun up, and the dependency was lost.
from cordova-plugin-network-information.
Related Issues (20)
- core.js:6014 ERROR RangeError: Maximum call stack size exceeded HOT 2
- bug: 'onConnect' does not work as expected HOT 10
- Refactor eslint to use cordova-eslint HOT 1
- Drop support for node < 10. HOT 1
- Version 2.0.2 from npmjs is crashing some devices with Android 10, on startup. HOT 9
- 5G detection HOT 13
- Correct network detection API calls deprecated on Android and iOS HOT 2
- network.connection.type is giving value as unknown in case of IOS 14 HOT 2
- Under no network conditions, start the App HOT 1
- What exactly is triggering online/offline events? HOT 2
- How to install specific version? HOT 2
- what 's new in version 3.0 ? should I need to update? HOT 1
- Issue with Ionic-native/network onConnect() on upgrade to Angular 10 HOT 1
- network.type is set to 'wifi' even when iPad Air is set to flight modus or when I am turning off WiFi
- Wrong typing for Connection
- 5G detect support HOT 4
- Network Up and Down Speed in android
- Navigator.connection support
- #throwInvalidProviderError HOT 1
- Adding this plugin breaks the build HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-network-information.