Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created November 5, 2016 22:08
Show Gist options
  • Save AppWerft/a31fdf98132077c37ae33809938c917f to your computer and use it in GitHub Desktop.
Save AppWerft/a31fdf98132077c37ae33809938c917f to your computer and use it in GitHub Desktop.
function bgServiceStart() {
console.log("bgServiceStart");
Ti.Geolocation.allowsBackgroundLocationUpdates = true;
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_LOW;
Ti.Geolocation.trackSignificantLocationChange = true;
var service = Ti.App.iOS.registerBackgroundService({
url : 'bg-service.js'
});
console.log("bgService registered");
}
module.exports = function() {
if (!Ti.Geolocation
.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE)) {
Ti.Geolocation.requestLocationPermissions(
Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) {
if (!e.success) {
Ti.API.error("Location permissions not granted: "
+ e.error);
return;
}
bgServiceStart();
});
} else
bgServiceStart();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment