0

i am working on cordova app for iOS in which i am getting user current location so that ask me about some message like that would you allow current position with options allow or don't allow. its fine but after that it again ask me like that show in image.

Message

How do i stop that message? or maybe change its text? also it second alert in first aper it just show me app name with confirmation about getting current location but after that this one appears again. Any help?

Acey
  • 8,048
  • 4
  • 30
  • 46
Blu
  • 4,036
  • 6
  • 38
  • 65

1 Answers1

0

To remove the alert, you have return the device's current position to the geolocationSuccess callback with a Position object as the parameter after the device is ready.

Use the below method. It will returns the device's current position as a Position object.

navigator.geolocation.getCurrentPosition(geolocationSuccess,
                                         [geolocationError],
                                         [geolocationOptions]);

Example:

$(function(){
  document.addEventListener("deviceready", onDeviceReady, false);
})

function onDeviceReady() {
  navigator.geolocation.getCurrentPosition(onSuccess, onError);     
}

function onSuccess(position) {
  // callback here 
}

function onError(error) { 
  // callback here
}

Please look at the phonegap documentation.

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102