1 Reply Latest reply on Nov 22, 2016 6:23 AM by VectorP

    deviceReady runs before ios permissions


      Hi everyone.

      I am currently working on A cordova/phonegap app, where the first page you encounter is a google map with your position..



      The first ting i do in the deviceReady function is to set the users position "navigator.geolocation.getCurrentPosition(geoSuccess, geoError, options);"


      But if i wait a few seconds before i press the permission dialog for "using the phones location" the geoError function will run.. But if i press the permission dialog fast enough, the map will load fine..


      i'm guessing that the problem is, that the app trys to get my location before i grant permission to get my location.


      if i am correct. how do i insure that the code will not run before permissions has been set, if it's even possible?


      device ready listener:

      document.addEventListener('deviceready', this.onDeviceReady, false);


      device ready function:

      onDeviceReady: function() {



           function setGeoPos(){

                  navigator.geolocation.getCurrentPosition(geoSuccess, geoError, {

                      enableHighAccuracy: true,




              function geoError(error) {




           function geoSuccess(position) {

                 coords = {lat: parseFloat(position.coords.latitude), lng: parseFloat(position.coords.longitude)};

                var map = new google.maps.Map(document.getElementById('map'), {

                        zoom: 13,

                        center: coords