Location Resolution Alert on iPhone with PhoneGap

How do you change the line in a warning saying:

(Appname / whatever) would like to use your current location

Of course I want to change the appname part. Because when you use the PhoneGap framework, the line is very ugly, something like this:

/var/mobile/Applications/157EB70D-4AA7-826E-690F0CBE0F/appname.app/www/index.html

Does anyone have an idea?

+51
iphone cordova core-location
Nov 04 '09 at 12:49
source share
19 answers

You need to perform geolocation after the device is ready. The following jQuery code, for example, will be grouped without this nasty warning:

$(function(){ document.addEventListener("deviceready", onDeviceReady, false); }) function onDeviceReady() { navigator.geolocation.getCurrentPosition(onSuccess, onError); } function onSuccess(position) { // your callback here } function onError(error) { // your callback here } 
+91
Feb 16 '11 at 15:39
source share

In Phonebook 3.0, you should answer Pius Uzamere and install the plugin.

 cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git 

otherwise, you will receive a double permission request.

+17
Sep 17 '13 at 1:19
source share

I just completed the documentation and solved it. Open a terminal and a CD in your project and enter the following command. $ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

Also add this to your config.xml

 <feature name="Geolocation"> <param name="ios-package" value="CDVLocation" /> </feature> 

He will solve this problem. :)

Source: http://docs.phonegap.com/en/3.0.0/cordova_geolocation_geolocation.md.html#The%20Command-line%0AInterface

+13
Jul 01 '14 at 18:53
source share

Although this question is much older, I found similar questions here and here .

For my permission, I had to add NSLocationWhenInUseUsageDescription to the NSLocationWhenInUseUsageDescription file. However, I suppose since my geolocation plugin was deprecated, I had to update it first. Then I had to remove / add the ICOS platform of Cordoba. Finally, I added NSLocationWhenInUseUsageDescription to the .plist file.

First remove / add the geolocation plugin:

 cordova plugin rm org.apache.cordova.geolocation cordova plugin add org.apache.cordova.geolocation 

Secondly, uninstall / add the iOS platform:

 cordova platform rm ios cordova platform add ios 

Finally, add NSLocationWhenInUseUsageDescription to the .plist. Open /platforms/ios/{project}/{project}-Info.plist and add the following:

 <key>NSLocationWhenInUseUsageDescription</key> <string>[App Name] would like to access your location when running and displayed.</string> 

See the iOS Developer Library link for more information on NSLocationWhenInUseUsageDescription vs. NSLocationAlwaysUsageDescription compared to NSLocationUsageDescription .

+8
Jun 09 '15 at 20:56
source share

Finally, the problem is fixed.

In index.html just move your cordova.js up

<script src = "cordova.js"> </script>

as the first js file to be included (especially make sure it is above the cards, including js). This will ensure that the prompt is displayed only once.

No other codes or ondeviceready required.

+6
Jul 18 '14 at 11:31
source share

None of the above answers worked for me. My location request has already shot girls. Adding the following to config.xml fixed:

 <gap:plugin name="org.apache.cordova.core.geolocation" /> 
+2
Dec 03 '13 at 22:29
source share

To solve the problem, I have to run the cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git , which adds (automatically) the following to the config.xml file:

 <feature name="Geolocation"> <param name="ios-package" value="CDVLocation" /> </feature> 

To get the job done, I must also put these lines in the config.xml file:

 <plugins> <plugin name="Device" value="CDVDevice" /> <plugin name="Logger" value="CDVLogger" /> <plugin name="Compass" value="CDVLocation" /> <plugin name="NetworkStatus" value="CDVConnection" /> <plugin name="Debug Console" value="CDVDebugConsole" /> <plugin name="Geolocation" value="CDVLocation" /> <plugin name="SplashScreen" value="CDVSplashScreen" /> <plugin name="Battery" value="CDVBattery" /> <plugin name="Globalization" value="CDVGlobalization" /> </plugins> 

Hope this can be helpful.

+2
Nov 07 '14 at 16:44
source share
  • By simply including the “cordova.js” file in your html file where you are accessing this location, solve this problem. NOTHING IS IMPOSSIBLE.
+1
Nov 30 '16 at
source share

After searching for the solution I founded, just add a variable when you add the plugin location, like this line

 cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="your usage message" 
+1
Aug 14 '17 at 14:00
source share

I'm late to the party here, but will answer the question for reference. The answer is to use the geolocation features found in phonegap.js, which is included in Phonegap. You can find such instructions on the Phonegap website at http://www.phonegap.com .

If you use navigator.geolocation , you use the default Safari geolocation system. This happens because PhoneGap works by efficiently managing your pages in a Safari instance. If you included phonegap.js on your site, you can use a separate geolocation method, which is called by PhoneGap Objective-C code, which will display the behavior observed in other applications, where it requests permission on behalf of your application.

0
Aug 04 '10 at 23:11
source share

1) change Location.m in the PhoneGapLib project. replace all links to navigator.geolocation with navigator_geo

2) Copy phonegap.js to phonegap2.js and paste it into the root application. I have now found out that every time I create an application and download it to a device or simulator, the phonegap.js file is restored. OK. Well, I need to change it, so let's just use a different and fuss upgrade in the future.

3) Change the line (in phonegap2.js) that creates the constructor for navigator.geolocation to 626 will be ... if (typeof navigator._geo == "undefined") navigator._geo = new Geolocation ();

4) Now that you want to use the PHONEGAP GPS material, you can link to it using navigator._geo.getCurrentPosition or similar 5) Enjoy ONE and PURE, showing your users your rationality to use PhoneGap and an application with HTML / JS.

* PRINTING AND PLEASE HELP! *

If I run the watchPosition function, I will get the first place to update all kinds of statistics. After that, he will always report an error. I guess this sucks for this 30 second time to get accurate GPS on these things?

http://groups.google.com/group/phonegap/browse_thread/thread/8067c2037816a9ad

0
Sep 16 '10 at 13:12
source share

I followed all the instructions, and he still failed. As a result, I played with the demo version of PhoneGap and found the final solution :

  • Move all js and html files to the same folder (not even a subfolder). Congratulations! The problem is resolved, there are no more warnings :)

  • By the way, you better use "setTimeout (function () {utility.getGeoData ();}, 1000); I found" document.addEventListener ("deviceready", utility.getGeoData (), false); not working for me.

Hope this helps when you don't find the solution above :)

Good luck

0
Mar 09 2018-11-11T00:
source share

Since I struggled for several days with the same problem and finally found a solution, I decided to share it with someone who could not fix it yet.

The solution is simple: the geolocation plugin was not in the plugins directory in the www directory, although I added the plugin via the phonegap command line interface. And the plugin files were in the / Plugins directory. Therefore, you only need to copy the missing files to / www / plugins, and you're done. Just.

If someone needs the missing files: http://d.pr/f/xqhq

btw: I am using cordova 3.2.0.

I hope this works for you too!

0
Dec 23 '13 at 9:15
source share

Phoengap / Cordova version 3.5 is here.

As in Manuel’s answer, but this time the plugin is not installed in the platform / ios / [appname] / Plugins folder.

The fix for me was to simply manually create a new folder for the plugin in the folder .. / platforms / ios / [appname] / Plugins> then rename it to org.apache.cordova.geolocation>, then copy. h and .m plugin files.

You can find the .m and .h files for the geoLocation plugin in the [root] /plugins/org.apache.cordova.geolocation/src/ios directory.

0
Nov 04 '14 at 17:33
source share

After my geolocation request was called after the device was ready, make sure the geolocation plugin is installed and configured correctly, I still got an unsightly pop-up window.

I resolved it by moving and referring to my cordova.js and cordova_plugins.js in the root directory of my application (they were originally in a subfolder), so the path to cordova.js would be as follows:

 <script src="cordova.js"></script> 

I believe this should be included in the documentation (maybe it is, but I could not find it)

0
Nov 28 '14 at 11:49
source share

Got this error (and much more) after updating Cordoba from 3.6 to 4.3.

I think there are some crashes during the upgrade process, and the only working solution for me was cordova platform rm ios , then cordova platform add ios

/! \ You will lose all your ios project settings and you need to reload the splash and icons.

0
Mar 05 '15 at 10:14
source share

In my case, I am using Cordova / Ionic and am experiencing the same problem. This is due to the code in front of the device. I just wrapped the code from document.addEventListener to "deviceready". For example:

 document.addEventListener("deviceready", function () { $cordovaGeolocation.getCurrentPosition(options).then(function(position){ ...your code here... }); }); 

Then an additional message does not appear.

0
May 02 '17 at 5:45 a.m.
source share

"Move all js and html files to the same folder (not even a subfolder). Congratulations! The problem is resolved, there are no more warnings :)" As Caleb says, it works for me, well, only moving the cord. js to the root and adding a plugin in config.xml

-one
May 7 '14 at 14:25
source share

What is the display name of the bundle of your project?

Try manually changing the default value of ${PRODUCT_NAME} and see ..

This permission to use location alerts only selects the display name of your package!

-2
Nov 04 '09 at 13:33
source share



All Articles