How do you change the string on the alert saying:
(Appname/whatever it is) would like to use your current location
Of course, I only want to change the appname part. Because when you use the PhoneGap framework, the string is very ugly, something like this:
/var/mobile/Applications/157EB70D-4AA7-826E-690F0CBE0F/appname.app/www/index.html
Someone having an idea?
None of the above answers worked for me. My location request was already firing on deviceready. Adding the following to config.xml fixed the issue:
Although this question is much older, I found similar questions here and here.
For my resolution, I had to add
NSLocationWhenInUseUsageDescription
to the .plist file. However, I suppose since my geolocation plugin was out of date, I had to update it first. Then I had to remove/add the Cordova iOS platform. Finally, I addedNSLocationWhenInUseUsageDescription
to the .plist file.First, remove/add the geolocation plugin:
Second, remove/add the iOS platform:
Last, add
NSLocationWhenInUseUsageDescription
to the .plist. Open/platforms/ios/{project}/{project}-Info.plist
and add the following:See this iOS Developer Library link for detailed information regarding
NSLocationWhenInUseUsageDescription
versusNSLocationAlwaysUsageDescription
versusNSLocationUsageDescription
.Since I was struggling for days now with the same problem and finally found the solution, I decided to share it with anyone who still was not able to fix it.
The solution is simple: The geolocation plugin was missing in the plugins directory within the www directory, even though I added the plugin via the phonegap command line interface AND the plugin files were in the /Plugins directory. So you only have to copy the missing files into /www/plugins and you are done. Just simple as that.
If anyone needs the missing files: http://d.pr/f/xqhq
btw: i am using cordova 3.2.0.
I hope this works for you as well!
Finally fixed the issue.
IN the 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 maps include js). This will make sure that the prompt shows only once.
No other codejs or ondeviceready is needed.
I followed all the instructions and it still failed. In the end I played around with the PhoneGap demo and found the final solution:
Move all the js files and html files into the same folder (not even sub-folder). Congratulations! Problem solved, no permission alert any more : )
BTW, You'd better use a " setTimeout(function(){utility.getGeoData();},1000);" I found "document.addEventListener("deviceready", utility.getGeoData(), false);" not work for me.
Hope that helps when you find no solution above : )
Good luck!