forked from intuit/LocationManager
/
INTULocationRequest.h
103 lines (85 loc) · 4.42 KB
/
INTULocationRequest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// INTULocationRequest.h
//
// Copyright (c) 2014-2015 Intuit Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import "INTULocationRequestDefines.h"
__INTU_ASSUME_NONNULL_BEGIN
/** The available types of location requests. */
typedef NS_ENUM(NSInteger, INTULocationRequestType) {
/** A one-time location request with a specific desired accuracy and optional timeout. */
INTULocationRequestTypeSingle,
/** A subscription to location updates. */
INTULocationRequestTypeSubscription,
/** A subscription to significant location changes. */
INTULocationRequestTypeSignificantChanges
};
@class INTULocationRequest;
/**
Protocol for the INTULocationRequest to notify the its delegate that a request has timed out.
*/
@protocol INTULocationRequestDelegate
/**
Notification that a location request has timed out.
@param locationRequest The location request that timed out.
*/
- (void)locationRequestDidTimeout:(INTULocationRequest *)locationRequest;
@end
/**
Represents a geolocation request that is created and managed by INTULocationManager.
*/
@interface INTULocationRequest : NSObject
/** The delegate for this location request. */
@property (nonatomic, weak, __INTU_NULLABLE) id<INTULocationRequestDelegate> delegate;
/** The request ID for this location request (set during initialization). */
@property (nonatomic, readonly) INTULocationRequestID requestID;
/** The type of this location request (set during initialization). */
@property (nonatomic, readonly) INTULocationRequestType type;
/** Whether this is a recurring location request (type is either Subscription or SignificantChanges). */
@property (nonatomic, readonly) BOOL isRecurring;
/** The desired accuracy for this location request. */
@property (nonatomic, assign) INTULocationAccuracy desiredAccuracy;
/** The maximum amount of time the location request should be allowed to live before completing.
If this value is exactly 0.0, it will be ignored (the request will never timeout by itself). */
@property (nonatomic, assign) NSTimeInterval timeout;
/** How long the location request has been alive since the timeout value was last set. */
@property (nonatomic, readonly) NSTimeInterval timeAlive;
/** Whether this location request has timed out (will also be YES if it has been completed). Subcriptions can never time out. */
@property (nonatomic, readonly) BOOL hasTimedOut;
/** The block to execute when the location request completes. */
@property (nonatomic, copy, __INTU_NULLABLE) INTULocationRequestBlock block;
/** Designated initializer. Initializes and returns a newly allocated location request object with the specified type. */
- (instancetype)initWithType:(INTULocationRequestType)type __INTU_DESIGNATED_INITIALIZER;
/** Completes the location request. */
- (void)complete;
/** Forces the location request to consider itself timed out. */
- (void)forceTimeout;
/** Cancels the location request. */
- (void)cancel;
/** Starts the location request's timeout timer if a nonzero timeout value is set, and the timer has not already been started. */
- (void)startTimeoutTimerIfNeeded;
/** Returns the associated recency threshold (in seconds) for the location request's desired accuracy level. */
- (NSTimeInterval)updateTimeStaleThreshold;
/** Returns the associated horizontal accuracy threshold (in meters) for the location request's desired accuracy level. */
- (CLLocationAccuracy)horizontalAccuracyThreshold;
@end
__INTU_ASSUME_NONNULL_END