rodrigo-md / cordova-dialog-gps

Plugin for phonegap/cordova to display a dialog and redirect to GPS settings when the GPS is disable.
MIT License
28 stars 21 forks source link

Can't use the plugin #14

Closed cperezvinsite closed 8 years ago

cperezvinsite commented 8 years ago

Hi I try to install the plugin into my cordova project with : cordova plugin add https://github.com/rodrigo-martinezd/cordova-dialog-gps.git

After that, and the success of cordova I try to implement the code, but when I do cordova.dialogGPS() I get the error TypeError: Object # has no method 'dialogGPS'
That's because cordova object has no dialogGPS on his structure, I don't know what to do.

If I run cordova plugin list I get this cl.rmd.cordova.dialoggps 0.0.2 "DialogGPS" And in the folder of plugins there is the dialogs plugin

By the way, I'm using cordova 5 Regards

rodrigo-md commented 8 years ago

Hi, you're right. If the error is that the object haven't no method. Is because the cordova object doesn't have dialogGPS and this occurs for two posibles reasons.

  1. You're calling "cordova.dialogGPS()" before the cordova object it's ready. it's for this that you must call inside a wrapper that listen for 'ready' event of cordova.
document.addEventListener('deviceready' , function() { 
    cordova.dialogGPS();
});
  1. The second possible reason is that in Cordova 5 has changed something I did not consider . I check the code to correct the error.

Please , try the first option and see if still does not work