This is a migrated thread and some comments may be shown as answers.

Disable GPS

3 Answers 58 Views
Feedback & Suggestions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brett
Top achievements
Rank 1
Brett asked on 15 Jul 2015, 08:42 AM

Hi,

Would be great to be able to disable GPS altogether so that it errors, the same way android devices do when trying to access geolocation functionality.

Brett

 

3 Answers, 1 is accepted

Sort by
0
Ventsislav Georgiev
Telerik team
answered on 17 Jul 2015, 03:20 PM
Hi Brett,

Thank you for contacting us.

I am not sure I understand your question. Could you please elaborate on your requirements and  in what kind of application (hybrid, native) you would like to disable the GPS. Please also provide information about which AppBuilder client you are using:
I assume you are looking for this functionality in the Device Simulator and if that is the case I can confirm that we have it logged as a feature request. However, I cannot yet commit to a time frame when it will become available.

Regards,
Ventsislav Georgiev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Brett
Top achievements
Rank 1
answered on 18 Jul 2015, 12:41 PM

Hi,

On a physical android device you can disable GPS altogether whereas in the appbuilder simulators (on all platforms) you can only set the location, not disable the functionality. 

 I would like to simulate switching GPS on and off within the application.

Thanks, 

Brett

0
Ventsislav Georgiev
Telerik team
answered on 21 Jul 2015, 03:34 PM
Hello Brett,

I'm afraid we don't have this functionality yet. We have it logged in as a feature request but I cannot commit to a time frame when it will become available. However you should be able to simulate disabling the GPS in the simulator by overriding the behavior of the navigator.geolocation.getCurrentPosition function.

Add this JavaScript code to your application:
window.disableGPS = false;
var defaultGetCurrentPosition = navigator.geolocation.getCurrentPosition;
navigator.geolocation.getCurrentPosition = function () {
    if(window.disableGPS && arguments.length >= 2 && typeof(arguments[1]) == 'function') {
        var positionError = new PositionError(PositionError.PERMISSION_DENIED, "The GPS has been switched off.");
        arguments[1](positionError);
    }
    else {
        defaultGetCurrentPosition.apply(navigator.geolocation, arguments);
    }
};

This way you could simulate GPS disabling by using the Debug-In-Simulator functionality and changing the flag in the Console pane:
window.disableGPS = true

If you need any further assistance don't hesitate to contact us.

Regards,
Ventsislav Georgiev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
Feedback & Suggestions
Asked by
Brett
Top achievements
Rank 1
Answers by
Ventsislav Georgiev
Telerik team
Brett
Top achievements
Rank 1
Share this question
or