Skip to content

Commit

Permalink
update README with updateFrequency parameter and replace println
Browse files Browse the repository at this point in the history
  • Loading branch information
Tres Spicher committed Dec 3, 2015
1 parent 6e3ec5a commit 7e29801
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,34 @@ func startLocationUpdates() {
let request = LocationUpdateRequest(accuracy: .Good) { (success, location, error) -> Void in
if success {
if let actualLocation = location {
println("LISTENER 1: success! location is (\(actualLocation.coordinate.latitude), \(actualLocation.coordinate.longitude))")
print("LISTENER 1: success! location is (\(actualLocation.coordinate.latitude), \(actualLocation.coordinate.longitude))")
}
} else {
if let theError = error {
println("LISTENER 1: error is \(theError.localizedDescription)")
print("LISTENER 1: error is \(theError.localizedDescription)")
}
}
}

// Register the listener
if let addListenerError = LocationUpdateService().registerListener(self, request: request) {
println("LISTENER 1: error in adding the listener. error is \(addListenerError.localizedDescription)")
print("LISTENER 1: error in adding the listener. error is \(addListenerError.localizedDescription)")
} else {
println("LISTENER 1 ADDED")
print("LISTENER 1 ADDED")
}
}
```

Note that there can be an error in setting up the request and that is returned right away rather than in the handler block. You should check for that.

It is also possible to limit the callback frequency using the `updateFrequency` parameter of `LocationUpdateRequest` like so:

```Swift
let request = LocationUpdateRequest(accuracy: .Good, updateFrequency: .ChangesOnly, ...)
```

Combining `accuracy: .Coarse` with `updateFrequency: .ChangesOnly` yields the lowest battery usage, at the expense of less accurate location data.

## Contributions

We appreciate your contributions to all of our projects and look forward to interacting with you via Pull Requests, the issue tracker, via Twitter, etc. We're happy to help you, and to have you help us. We'll strive to answer every PR and issue and be very transparent in what we do.
Expand Down

0 comments on commit 7e29801

Please sign in to comment.