Location permission alert on iPhone with Cordova
Same as the "edit" in the original question, I had to remove the old version of the geolocation plugin and add the new one. Then I had to remove/add the Cordova iOS platform. Only then could I add NSLocationWhenInUseUsageDescription
to the .plist file as DaveAlden mentions in his answer with success.
First, remove/add the geolocation plugin:
cordova plugin rm org.apache.cordova.geolocation
cordova plugin add org.apache.cordova.geolocation
Second, remove/add the iOS platform:
cordova platform rm ios
cordova platform add ios
Last, 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 this iOS Developer Library link for detailed information regarding NSLocationWhenInUseUsageDescription
versus NSLocationAlwaysUsageDescription
versus NSLocationUsageDescription
.
Cordova iOS location message
The solution has changed for cordova-plugin-geolocation: "4.0.0". This is what you need to add in your config.xml
:
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>
For more information: https://github.com/apache/cordova-plugin-geolocation
Location permission alert shows up twice using Phonegap
I finally figured it out, I added the following lines and the second alert no longer shows up
<script src="index.js"></script>
<script src="cordova.js"></script>
Has anyone faced Geolocation permission alert for iOS showing twice issue along with bundle location?
I finally solved this with on device ready function loading to body tag
function onDeviceReady(){
return navigator.geolocation.getCurrentPosition(initialize);
document.addEventListener("backbutton", onBackKeyDown, false);
}
function onLoad()
{
if (typeof navigator.device == "undefined"){
document.addEventListener("deviceready", onDeviceReady, false);
} else {
onDeviceReady();
}
}
<body onload="onLoad();">
Related Topics
Jqm Ui-Content 100% Height Issue
Jquery/Js:Detect User's Scroll Attempt Without Any Window Overflow to Scroll To
JavaScript Not Working in Android Webview
Get Pixelcolor of CSS Background Image
Disable iPhone "Save Image" Popup
Conflict Between Jquery and Bootstrap
Angular App Not Loading CSS and Js on Refreshing Page
After Content Update from Ajax Jquery Not Work Properly
iOS 11 Getusermedia Not Working
Using Cookies to Retain Stylesheet Preference Across Website
How to Achieve a Consistent Layout in All Browsers
Primefaces Dialog with Modal=True Not Working Properly
Make the Change of "Active" Class in the Menu More Reliable When Scrolling
Handle Webpack CSS Imports When Testing with Mocha and Babel
Webkit Transitionend Event Grouping