This is a follow up from: Location permission alert on iPhone with PhoneGap
image: http://imgur.com/c2KBqbm
None of the answers there worked and I am still getting the "/private/var ... would like to use your location" message. I have $cordovaGeolocation in a factory
.factory('$cordovaGeolocation', ['$q', 'geo', function ($q) {
return {
getCurrentPosition: function (options) {
var q = $q.defer();
navigator.geolocation.getCurrentPosition(function (result) {
q.resolve(result);
console.log(JSON.stringify(q.resolve(result)));
}, function (err) {
q.reject(err);
}, options);
return q.promise;
},
watchPosition: function (options) {
var q = $q.defer();
var watchID = navigator.geolocation.watchPosition(function (result) {
q.notify(result);
}, function (err) {
q.reject(err);
}, options);
q.promise.cancel = function () {
navigator.geolocation.clearWatch(watchID);
};
q.promise.clearWatch = function (id) {
navigator.geolocation.clearWatch(id || watchID);
};
q.promise.watchID = watchID;
return q.promise;
},
clearWatch: function (watchID) {
return navigator.geolocation.clearWatch(watchID);
}
};
}])
and call it in a resolve in my .state
resolve : {
initialGeo: function ($cordovaGeolocation) {
var posOptions = {timeout: 1000, enableHighAccuracy: true};
return $cordovaGeolocation.getCurrentPosition(posOptions);
}
}
I cannot get rid of this awful message. I'm using the latest ionic and cordova versions with the plain 'ol phonegap geolocation plugin.
What I've tried: - Changes to the config.xml
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
<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>
Ripping out the factory and just doing
document.addEventListener("deviceready", function(){ navigator.geolocation.getCurrentPosition(onsuccess, onerror, params); }, false);
Moving cordova.js to the first script to be loaded.
- Move all js files to root.
The normal permission alert shows once. The ugly one shows 2-3 times and then doesn't show again.
Any help would be greatly appreciated.