Reputation: 445
I'm creating an ios app with phonegap 3.2 I need users current location to search nearby users. When i tried to get current location of device with code
function onSuccess(position) {
device_lat = position.coords.latitude;
device_long = position.coords.longitude;
}
// onError Callback receives a PositionError object
function onError(error) {
alert("Share Your Location First.");
}
function onDeviceReady()
{
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
A confirm box appearing with following text. "/Users/../Library/Application Support/iPhone Simulators/6.1/Applications/[App Code here]/demo.app/www/index.html" Would Like To Use Your Current Location.
Is it possible to costomise this text as its say Like "MyApp Would Like To Use Your Current Location" ?
Also for android and other devices.
Upvotes: 5
Views: 1557
Reputation: 445
I removed cordova geolocation plugin and everything working well. I'm using phonegap 3.
navigator.geolocation.getCurrentPosition(onSuccess, onError); is also a html5 function so no need to other changes. Now it giving confirm box with message.
"MyApp Would Like To Use Your Current Location"
MyApp is the title of index page.
Upvotes: 0
Reputation: 1310
I'm posting a new answer since the last one was incomplete. In order to get the geolocation prompt title to show your app name and not the full path to the file you'll need to do two things:
Install the Cordova / PhoneGap geoLocation pluin (cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git)
Run the getCurrentPosition after deviceready has been fired.
Upvotes: 1
Reputation: 2701
$(document).ready(function(){
$(function(){
document.addEventListener("deviceready", onDeviceReady, false);
})
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
});
Upvotes: 0