Cordova Geolocation plugin and popup "confirmation" with url application name. How Solve?

I finished an app that use geoloc function. I’ve the problem that appear popup message confirmation that request access to position where there is the /var/mobile/Applications//Documents/index.html.
How solve this problem?
How check if cordova plugins are on?

1 Like

Could you post a screenshot of said popup?
I don’t know with cordova geolocation, but when you work with the navigator geolocation (HTML5), on mobile there is no need to ask the user for permission. Just works if the GPS is On, or fails if its off.

Hey sorry for not understanding 100% what you mean, but I think you’re asking how to remove the app file location form the alert title?

If so, use the cordova dialog plugin

This is the screen:

this is the script to check if device is ready, but I think that it starts after angularjs/ionic…I get GEOposition to change background like ionic weather app.


      document.addEventListener("deviceready", onDeviceReady, false);

      function onDeviceReady() {
        console.log("deviceready now");
        navigator.geolocation.getCurrentPosition(onSuccess, onError); 
        //if (parseFloat(window.device.version) === 7.0) {
        // = "20px";


      function onSuccess(position) {
            // your callback here 

      function onError(error) { 
            // your callback here


I see if I comment this code into my factory module that message disappear. I think because it execuded before Cordova device ready event. I’ve already added geo plugin.

getLocation: function() {
      var q = $q.defer();

      navigator.geolocation.getCurrentPosition(function(position) {
      }, function(error) {
        console.log("Errore posizione " + error.code + "-" + error.message );

      return q.promise;

How solve? You can see this issue into your app.

Have someone the same problem? I think that ‘deviceready’ event start after controller/directives.

hey, have you found a fix for that? I’m running into the same problem right now for days and I can’t figure it out :frowning:
Please reply if you got something :smiley:

Hi, not at the moment. I’ve not try again until now.

I don’t get the second alert popup (just the first one which is clean) as you have mentioned (i.e. no index.html in popup) :smiley:


16   .controller('FriendsCtrl', function($scope, $ionicPlatform, $cordovaGeolocation, Friends) {
 17   $scope.friends = Friends.all();
 19   console.log("hi:hi");
 20   // geolocation [wip]
 21  $ionicPlatform.ready(function() {
 22 //document.addEventListener("deviceready", function () {
 23   console.log("now ready");
 24   var posOptions = {timeout: 10000, enableHighAccuracy: false};
 25   $cordovaGeolocation
 26     .getCurrentPosition(posOptions)
 27     .then(function (position) {
 28       $  = position.coords.latitude
 29       $scope.long = position.coords.longitude
 31       // alert($;
 32     }, function(err) {
 33       console.log("Error occurred!");
 34     });
 35 // }, false);
 36 });
 37 })

tabs-friends.html (used lat and long here)

  1 <ion-view view-title="Friends">
  2   <ion-content>
  3     <ion-list>
  4       <ion-item class="item-avatar" ng-repeat="friend in friends" type="item-text-wrap" href="#/tab/friend/{{}}">
  5         <img ng-src="{{friend.face}}">
  6         <h2>{{}}</h2><h3>{{lat}}</h3><h3>{{long}}</h3>
  7       </ion-item>
  8     </ion-list>
  9   </ion-content>
 10 </ion-view>

for the sake of completion:

sudo npm install -g cordova ionic
cordova plugin add org.apache.cordova.geolocation
ionic platform rm ios (necessary)
ionic platform add ios
ionic build ios
ionic emulate ios

To make it work, I had to do this a couple of times:

IOS simulator --> Reset content and Settings.. 

:sunglasses: :sunglasses: :sunglasses:

However I do get second popup if I put some ugly code like this in the controller.js:


Ionic view on iphone does not support cordova geolocation so, it didnt work there.

:open_mouth: thats my real location, do not bomb me! :open_mouth:

I’ve answered this on my own topic, you can’t call navigator inside your controller, you have to call it inside your app.js inside $ionicPlatform.ready(function() {
That will make the ugly pop up dissapear. I hope it gets fixed

Where do you have this information from @betoharres ? You can call $ionicPlatform.ready() from anywhere, as it is described in the docs -

It basically works like the deviceready listener, only that it is also triggered when working in the desktop browser emulator. And of course you can also call navigator in the controller, or service or whereever in your JS code.

1 Like

THX for your share of this question

+1 for this

@mhartington Can you quick view image below:


Title not good at here

Hi did you find a solution for this in the end?

Same. Adding NSLocationWhenInUseUsageDescription string to AppName-Info.plist just gets cleared out when I run ionic build ios.


I get that message too, but ONLY when I use Ionic View.

When I deploy to my iphone 5 it works fine and I only get the first (normal) dialog.
I added the cordova-plugin-dialogs and I am using $ionicPlatform.ready from my controllers.js …


I’m getting the same alert with the message: " “/var/mobile/Containers/…/…/” Would Like To Use Your Current Location ", and I found some tips but, none works well. I saw something like:

Add these keys to ${PROJECT_NAME}-Info.plist

NSLocationWhenInUseUsageDescription, NSLocationUsageDescription and NSLocationAlwaysUsageDescription

But I had no success yet. Someone can help us?


I get the following error with the cordova diagnostics plugin. Any ideas please?

hi @phanthinh, did you find solution for this issue. Please let me know.