Avi
Avi

Reputation: 445

geolocation confirm box showing my index file url in phonegap ios application

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

Answers (3)

Avi
Avi

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

Eirik Hoem
Eirik Hoem

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:

  1. Install the Cordova / PhoneGap geoLocation pluin (cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git)

  2. Run the getCurrentPosition after deviceready has been fired.

Upvotes: 1

Ved
Ved

Reputation: 2701

$(document).ready(function(){                      

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

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

});

Upvotes: 0

Related Questions