Can't get geolocation prompt on iOS

Created a blank TABS ionic app
Added the cordova geolocation example code from cordova docs
Run on iOS devices

I never get a prompt to allow access to the GPS / geo location data and never get any numbers back.

However I don’t appear to get any errors either.

Anyone have any ideas or suggestions on how to get geolocation working in ionic ?

Example code below.
hello1 shows but hello2 never does

<!DOCTYPE html>
    <title>Device Properties Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load

    document.addEventListener("deviceready", onDeviceReady, false);
    // Cordova is ready
    function onDeviceReady() {
        navigator.geolocation.getCurrentPosition(onSuccess, onError);

    // onSuccess Geolocation
    function onSuccess(position) {
        var element = document.getElementById('geolocation');
        element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                            'Longitude: '          + position.coords.longitude             + '<br />' +
                            'Altitude: '           + position.coords.altitude              + '<br />' +
                            'Accuracy: '           + position.coords.accuracy              + '<br />' +
                            'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                            'Heading: '            + position.coords.heading               + '<br />' +
                            'Speed: '              + position.coords.speed                 + '<br />' +
                            'Timestamp: '          +                                   position.timestamp          + '<br />';

    // onError Callback receives a PositionError object
    function onError(error) {
        alert('code: '    + error.code    + '\n' +
                'message: ' + error.message + '\n');

    <p id="geolocation">Finding geolocation...</p>

Ok, so I think I worked it out. I was’t including the plugin properly in my app.js starter. Appears to all be working now :slight_smile:

1 Like

Hey sorry for taking so long to respond back, but glad you got this resolved :smile:

1 Like

How you include the plugin in your app.js?

@fox, how did you managed that? I am facing a similar problem in iOS 10. Thanks.

Hi @mhartington.
Please, can you help me with my issue?
It’s related to this one but, so far, I couldn’t resolve it. I tried every single suggestion I could find on the Ionic forum but nothing worked.