I am able to turn it off.
code:
//get current Location
//
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = .25;
var overlays = require('overlays');
//check if gps is enabled
exports.checkGPS = function(windowCur) {
Ti.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
// make the API call
var wrapperW = overlays.wrapperOverlay(windowCur);
Ti.Geolocation.getCurrentPosition(function(e) {
// do this stuff when you have a position, OR an error
if (e.error) {
Ti.API.error('geo - current position' + e.error);
//put overlay on
overlays.GPSError(windowCur);
return;
}else{
//alert(JSON.stringify(windowCur));
wrapperW.hide();
}
});
};
This works fine at getting whether the user has turned on or off their location services. An overlay is put on the screen informing the user they need to turn it on, if they have turned it off.
However the problem is after the user has set it, and then goes into settings -> location services and enabled it, I am unable to take the overlay off as I have know way off tracking in real time if it has been turned on or off.
Does anyone know how this can be achieved, cheers.
UPDATE:
This did the trick
var wrapperW = null;
Titanium.Geolocation.addEventListener('location', function(e) {
if (e.error) {
//put overlay on
wrapperW = overlays.GPSError($.win);
} else {
//keep updating
Ti.API.info(e.coords);
if (wrapperW != null) {
wrapperW.hide();
}
}
});
UPDATE:
This did the trick
var wrapperW = null;
Titanium.Geolocation.addEventListener('location', function(e) {
if (e.error) {
//put overlay on
wrapperW = overlays.GPSError($.win);
} else {
//keep updating
Ti.API.info(e.coords);
if (wrapperW != null) {
wrapperW.hide();
}
}
});