Last active
October 16, 2015 15:15
-
-
Save SteveTrewick/90540473a52a313c82b8 to your computer and use it in GitHub Desktop.
Swift ios9 background core location
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
/* | |
In your .plist : | |
<key>UIBackgroundModes</key> | |
<array> | |
<string>location</string> | |
</array> | |
... | |
<key>UIRequiredDeviceCapabilities</key> | |
<array> | |
... | |
<string>gps</string> | |
<string>location-services</string> | |
</array> | |
... | |
<key>NSLocationWhenInUseUsageDescription</key> | |
<string>App requires access to GPS when in use</string> | |
... | |
*/ | |
// given self.locman is an initialised CLLocationManager | |
self.locman.requestWhenInUseAuthorization() | |
self.locman.desiredAccuracy = kCLLocationAccuracyBest | |
self.locman.activityType = .Fitness | |
self.locman.allowsBackgroundLocationUpdates = true // << THIS, or you won't get any background time | |
self.locman.startUpdatingLocation() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment