Software Archive
Read-only legacy content
17061 Discussions

Verificar se está usando Wireless

Dani_Carla
Beginner
757 Views

Olá gente, boa tarde.

Estou fazendo meu APP e queria fazer uma verificação para ver se o usuário está conectado ao Wireless...
Não tenho nem ideia de como fazer isso, podem me ajudar?

Obrigada!

0 Kudos
3 Replies
Hamilton_Tenório_da_
Valued Contributor I
757 Views

Você pode fazer assim:

    var estadoInternet = navigator.connection.type;
    switch(estadoInternet) {
        case "none":
            (... alguma coisa...)
        case "unknown":
            (... alguma coisa...)
        case "wifi":
            (... alguma coisa...)
        case "ethernet":
            return true;
        default:
            (... alguma coisa...)
    }

 

 

0 Kudos
Elroy_A_Intel
Employee
757 Views

I recommend using the Connection (Network Information) Apache Cordova* plugin. This plugin allows you to get information about the connection type as well as whether there is an active connection as well. You can add and select this plugin to your project under the Projects Panel > Cordova Hybrid Mobile App Settings > Included Plugins > Standard Cordova Plugins > Connection.

For more information about the plugin, visit https://github.com/apache/cordova-plugin-network-information,

0 Kudos
Dani_Carla
Beginner
757 Views

Thanks guys!

0 Kudos
Reply