Cordova geolocation always getting timeout

In browser this plugin is working but on real android device it is keep on getting timeout error.
I am using redmi and android 4.3
This is my code:

   $ionicPlatform.ready(function() {
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        console.log("navigator.geolocation works well");
        var posOptions = {
        enableHighAccuracy: true,
        timeout: 20000,
        maximumAge: 0
    .then(function (position) {
      var lat  = position.coords.latitude
      var long = position.coords.longitude
    }, function(err) {
      // error


I am using following option.
var posOptions = {
enableHighAccuracy: true,
timeout: 20000,
maximumAge: 0

How to fix this problem.

I think your Gps not synchronize 20s.
The Browser uses the IP address to locate, if you want to be in the same condition changes enableHightAccuracy to false. Indoor GPS take more time to synchronize and often this is not possible.

Is there any other way to get current location . I want current location coordinates.

I get the same error. It is always error code = 3 . TIMEOUT. I use this setup:
var posOptions = {timeout: 20000, enableHighAccuracy: false};

anyone knows the reason?

If the app starts with GPS on from the beginning. it works perfectly.
In case the App starts with GPS off , and later you turn GPS on, the plugin gets always timeout . error code = 3. no solution for this issue until now.
I share code example