Skip to content

Commit 22641ab

Browse files
committed
Merge tag '2.0.6' into develop
2.0.6
2 parents cb26dbf + 183c9d5 commit 22641ab

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

Sources/SwiftLocation/LocationRequest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ public class LocationRequest: Request {
265265

266266
// Remove request from queue if some conditions are verified
267267
stopRequestIfNeeded()
268+
// Stop and restart timeout timer if needed
269+
startTimeout()
268270
}
269271

270272
private func isValidMinimumDistance(_ loc: CLLocation) -> Bool {

Sources/SwiftLocation/LocationTracker.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,14 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
230230
/// - timeout: optional timeout. If no location were found before timeout a `LocationError.timeout` error is reported.
231231
/// - success: success handler to call when a new location were found for this request
232232
/// - error: error handler to call when an error did occour while searching for request
233+
/// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
233234
/// - Returns: request
234235
@discardableResult
235-
public func getLocation(accuracy: Accuracy, frequency: Frequency, timeout: TimeInterval? = nil, success: @escaping LocObserver.onSuccess, error: @escaping LocObserver.onError) -> LocationRequest {
236+
public func getLocation(accuracy: Accuracy, frequency: Frequency, timeout: TimeInterval? = nil, cancelOnError: Bool = false, success: @escaping LocObserver.onSuccess, error: @escaping LocObserver.onError) -> LocationRequest {
236237

237238
let req = LocationRequest(accuracy: accuracy, frequency: frequency, success, error)
238239
req.timeout = timeout
240+
req.cancelOnError = cancelOnError
239241
req.resume()
240242
return req
241243
}
@@ -250,15 +252,16 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
250252
/// specific geographical area, which is typically the user’s current location.
251253
/// - timeout: timeout of the operation; nil to ignore timeout, a valid seconds interval. If reverse geocoding does not succeded or
252254
/// fail inside this time interval request fails with `LocationError.timeout` error and registered callbacks are called.
255+
/// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
253256
///
254257
/// - success: success handler to call when reverse geocoding succeded
255258
/// - failure: failure handler to call when reverse geocoding fails
256259
/// - Returns: request
257260
@discardableResult
258-
public func getLocation(forAddress address: String, inRegion region: CLRegion? = nil, timeout: TimeInterval? = nil,
259-
success: @escaping GeocoderObserver.onSuccess, failure: @escaping GeocoderObserver.onError) -> GeocoderRequest {
261+
public func getLocation(forAddress address: String, inRegion region: CLRegion? = nil, timeout: TimeInterval? = nil, cancelOnError: Bool = false, success: @escaping GeocoderObserver.onSuccess, failure: @escaping GeocoderObserver.onError) -> GeocoderRequest {
260262
let req = GeocoderRequest(address: address, region: region, success, failure)
261263
req.timeout = timeout
264+
req.cancelOnError = cancelOnError
262265
req.resume()
263266
return req
264267
}
@@ -307,14 +310,16 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
307310
///
308311
/// - Parameters:
309312
/// - filter: The minimum angular change (measured in degrees) required to generate new heading events.
313+
/// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
310314
/// - success: succss handler
311315
/// - failure: failure handler
312316
/// - Returns: request
313317
@discardableResult
314-
public func getContinousHeading(filter: CLLocationDegrees,
315-
success: @escaping HeadingObserver.onSuccess, failure: @escaping HeadingObserver.onError) throws -> HeadingRequest {
318+
public func getContinousHeading(filter: CLLocationDegrees, cancelOnError: Bool = false,
319+
success: @escaping HeadingObserver.onSuccess, failure: @escaping HeadingObserver.onError) throws -> HeadingRequest {
316320
let request = try HeadingRequest(filter: filter, success: success, failure: failure)
317321
request.resume()
322+
request.cancelOnError = cancelOnError
318323
return request
319324
}
320325

@@ -326,16 +331,18 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
326331
/// - Parameters:
327332
/// - center: coordinate center
328333
/// - radius: radius in meters
334+
/// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
329335
/// - enter: callback for region enter event
330336
/// - exit: callback for region exit event
331337
/// - error: callback for errors
332338
/// - Returns: request
333339
/// - Throws: throw `LocationError.serviceNotAvailable` if hardware does not support region monitoring
334340
@discardableResult
335-
public func monitor(regionAt center: CLLocationCoordinate2D, radius: CLLocationDistance,
341+
public func monitor(regionAt center: CLLocationCoordinate2D, radius: CLLocationDistance, cancelOnError: Bool = false,
336342
enter: RegionObserver.onEvent?, exit: RegionObserver.onEvent?, error: @escaping RegionObserver.onFailure) throws -> RegionRequest {
337343
let request = try RegionRequest(center: center, radius: radius, onEnter: enter, onExit: exit, error: error)
338344
request.resume()
345+
request.cancelOnError = cancelOnError
339346
return request
340347
}
341348

@@ -344,15 +351,17 @@ public final class LocationTracker: NSObject, CLLocationManagerDelegate {
344351
///
345352
/// - Parameters:
346353
/// - region: region to monitor
354+
/// - cancelOnError: if `true` request will be cancelled when first error is received (both timeout or location service error)
347355
/// - enter: callback for region enter event
348356
/// - exit: callback for region exit event
349357
/// - error: callback for errors
350358
/// - error: callback for errors
351359
/// - Throws: throw `LocationError.serviceNotAvailable` if hardware does not support region monitoring
352360
@discardableResult
353-
public func monitor(region: CLCircularRegion,
361+
public func monitor(region: CLCircularRegion, cancelOnError: Bool = false,
354362
enter: RegionObserver.onEvent?, exit: RegionObserver.onEvent?, error: @escaping RegionObserver.onFailure) throws -> RegionRequest {
355363
let request = try RegionRequest(region: region, onEnter: enter, onExit: exit, error: error)
364+
request.cancelOnError = cancelOnError
356365
request.resume()
357366
return request
358367
}

SwiftLocation.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SwiftLocation'
3-
s.version = '2.0.5'
3+
s.version = '2.0.6'
44
s.license = 'MIT'
55
s.summary = 'Efficent and Easy Location Monitoring in Swift'
66
s.homepage = 'https://github.com/malcommac/SwiftLocation'

SwiftLocation/SwiftLocation.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@
451451
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
452452
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
453453
COPY_PHASE_STRIP = NO;
454-
CURRENT_PROJECT_VERSION = 5;
454+
CURRENT_PROJECT_VERSION = 6;
455455
DEBUG_INFORMATION_FORMAT = dwarf;
456456
ENABLE_STRICT_OBJC_MSGSEND = YES;
457457
ENABLE_TESTABILITY = YES;
@@ -504,7 +504,7 @@
504504
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
505505
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
506506
COPY_PHASE_STRIP = NO;
507-
CURRENT_PROJECT_VERSION = 5;
507+
CURRENT_PROJECT_VERSION = 6;
508508
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
509509
ENABLE_NS_ASSERTIONS = NO;
510510
ENABLE_STRICT_OBJC_MSGSEND = YES;

0 commit comments

Comments
 (0)