Phonegap plugin scope


#1

I have a quick question regarding the availability of a phonegap plugin.

In my app I need to check if I am connected to the internet (wether, wifi, 3G, LTE …) in order to either alert the user or to call our service.
What I do is:

Experiences.all().then(function(experiences) {
            console.log(navigator.connection.type);
           //do business logic based on response here
        });

In this case, I get the type of connection just fine, but obviously this is not preferable since by now, the call to my service already caused an error.
However, if I try to get the connection type outside of the response of my service I get an error because navigator is not defined.

console.log(navigator.connection.type);
    Experiences.all().then(function(experiences) {
                
               //do business logic based on response here
            });

Any help would be appreciated :slight_smile:


#2

Take a look at this…

These are angular wrappers for cordova plugins that keep all your functions in scope.


#3

sweet thanks :smile: