Created
November 5, 2016 22:08
-
-
Save AppWerft/a31fdf98132077c37ae33809938c917f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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