Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7562213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:21:35+00:00 2026-05-30T13:21:35+00:00

I have an application that is making use of the PhoneGap (version 1.4.1). It

  • 0

I have an application that is making use of the PhoneGap (version 1.4.1). It is not a normal PhoneGap application as the application has been built with MonoTouch, not Xcode. The PhoneGap library is being loaded into a IUWebView and the phonegap-1.4.1.js file is located on a remote server. I can call the functions in the PhoneGap API and everything works fine; the only problem I have is with the PhoneGap Geolocation API. Although geolocation works, everytime the webpage is loaded a request for permission is made to use the iPhone locations services, but it does not request permission for my application name, it requests permission for the URL where the page source is located. So the alert will say “http://xxx.xxx.xxx.xxx would like to use your current location” and I the user answers “Allow”, the iphone does not remember this because it will ask again the next time the page is reloaded.

Does anyone know why my call to the PhoneGap geolocation API is doing this? And is some way for me to get PhoneGap to request permission for my application to use location services, rather than the URL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:21:36+00:00Added an answer on May 30, 2026 at 1:21 pm

    I found the solution to this problem. PhoneGap does a replacement of all UIWebView/MobileSafari navigator.geolocation functions with its own functions so that a call to a navigator.geolocation function will execute the corresponding PhoneGap function. To see where this is happening in the javascript source code, search for the following line:

    if (typeof navigator._geo == "undefined") 
    

    The description directly under this line describes the problem outlined in this question that PhoneGap is trying to avoid. The main problem, though, was that I was executing the following in jquery’s document.ready handler:

    navigator.geolocation.getCurrentPosition(onGpsSuccess, onGpsError, { enableHighAccuracy: true });

    and at this point in the execution the PhoneGap initialization had not yet been completed, so the call to navigator.geolocation.getCurrentPosition called MobileSafari’s version of getCurrentPosition, not PhoneGap’s. I determined that the initialization was not completed by putting alert(navigator._geo); in document.ready and found that it returned undefined.

    The solution then was to replace the line of code in the document.ready with the following:

    document.addEventListener("deviceready", function() {
        navigator.geolocation.getCurrentPosition(onGpsSuccess, onGpsError, { enableHighAccuracy: true });
    }, false); 
    

    This ensures that navigator.geolocation is only called when PhoneGap has completed its initialization.

    So, if you encounter this problem, then check the following:

    1. You are using the latest version of PhoneGap where this issue is dealt with.
    2. You are not trying to make use of navigator.geolocation before PhoneGap is ready.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an application for the iPad. I have a view controll that has
I have a Zend Framework application that is making use of jQuery UI. In
I'm making an application that makes use of session variables. I have created a
I have a web application that has been running just fine in Internet Explorer
I have a application that's making calls against some WCF services I have hosted
I have a Monodroid application that does many webrequests. I am making requests from
So, I have an application I'm making that can be simply described as a
I'm making a swing based application where I have a JList that periodically get's
I am making a new application in MongoDB, and I have found that the
I currently have an application making use of Authorize.net's ARB API. I have everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.