Alfred Alfizo Mosima
Alfred Alfizo Mosima

Reputation: 721

Phonegap enable gps services

Im writting a phonegap app that uses gps. I want to be able to redirected to gps settings so that i can switch it on. how can i achieve that. All the previous articles show how to enable gps at run time and the code is deprecated.

Upvotes: 3

Views: 4699

Answers (2)

DaveAlden
DaveAlden

Reputation: 30356

Specifically for Android, you could use cordova-plugin-request-location-accuracy to switch on/increase accuracy of Location services from within your app (similar to how Google Maps does it).

This avoids needing to switch to the Location settings page and have the user manually change Location mode to enable GPS.

Upvotes: 2

Alfred Alfizo Mosima
Alfred Alfizo Mosima

Reputation: 721

after struggling for a while i found a plugin that was able to help me with my problem.

http://devpost.com/software/cordova-dialog-gps

  function calldialog() {
  document.addEventListener("deviceready",function() {
  cordova.dialogGPS("Your GPS is Disabled, this app needs to be enable to      works.",//message
                "Use GPS, with wifi or 3G.",//description
                function(buttonIndex){//callback
                  switch(buttonIndex) {
                    case 0: break;//cancel
                    case 1: break;//neutro option
                    case 2: break;//user go to configuration
                  }},
                  "Please Turn on GPS",//title
                  ["Cancel","Later","Go"]);//buttons
 });
 }    

Upvotes: 1

Related Questions