Coder Social home page Coder Social logo

Comments (9)

elbartostrikesagain avatar elbartostrikesagain commented on June 14, 2024 4

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.

hriziya avatar hriziya commented on June 14, 2024 1

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.

anaaChacon avatar anaaChacon commented on June 14, 2024 1

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.

breautek avatar breautek commented on June 14, 2024 1

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.

janpio avatar janpio commented on June 14, 2024

What is your actual code? Or is it just the one line you posted?

from cordova-plugin-network-information.

CenaSurya avatar CenaSurya commented on June 14, 2024

navigate is undefined

from cordova-plugin-network-information.

jcesarmobile avatar jcesarmobile commented on June 14, 2024

are you waiting for device ready event before calling the plugin code?

from cordova-plugin-network-information.

gijsbeijer avatar gijsbeijer commented on June 14, 2024

@elbartostrikesagain Worked for me! thanks!

from cordova-plugin-network-information.

Classic-Paterson avatar Classic-Paterson commented on June 14, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.