@josuelmm/capacitor-background-geolocation 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/JosuelmmCapacitorBackgroundGeolocation.podspec +34 -0
  2. package/LICENSE +17 -0
  3. package/NOTICE.md +32 -0
  4. package/Package.swift +45 -0
  5. package/README.md +402 -0
  6. package/android/build.gradle +79 -0
  7. package/android/proguard-rules.pro +1 -0
  8. package/android/src/main/AndroidManifest.xml +83 -0
  9. package/android/src/main/java/com/evgenii/jsevaluator/HandlerWrapper.java +18 -0
  10. package/android/src/main/java/com/evgenii/jsevaluator/JavaScriptInterface.java +22 -0
  11. package/android/src/main/java/com/evgenii/jsevaluator/JsEvaluator.java +133 -0
  12. package/android/src/main/java/com/evgenii/jsevaluator/JsFunctionCallFormatter.java +37 -0
  13. package/android/src/main/java/com/evgenii/jsevaluator/WebViewWrapper.java +71 -0
  14. package/android/src/main/java/com/evgenii/jsevaluator/interfaces/CallJavaResultInterface.java +8 -0
  15. package/android/src/main/java/com/evgenii/jsevaluator/interfaces/HandlerWrapperInterface.java +5 -0
  16. package/android/src/main/java/com/evgenii/jsevaluator/interfaces/JsCallback.java +10 -0
  17. package/android/src/main/java/com/evgenii/jsevaluator/interfaces/JsEvaluatorInterface.java +18 -0
  18. package/android/src/main/java/com/evgenii/jsevaluator/interfaces/WebViewWrapperInterface.java +14 -0
  19. package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/BackgroundGeolocationPlugin.java +898 -0
  20. package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/ConfigMapper.java +303 -0
  21. package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/HeadlessTaskRegistry.java +34 -0
  22. package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/JsEvaluatorTaskRunner.java +63 -0
  23. package/android/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +699 -0
  24. package/android/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +103 -0
  25. package/android/src/main/java/com/marianhello/bgloc/Config.java +1155 -0
  26. package/android/src/main/java/com/marianhello/bgloc/ConnectivityListener.java +5 -0
  27. package/android/src/main/java/com/marianhello/bgloc/HttpPostService.java +362 -0
  28. package/android/src/main/java/com/marianhello/bgloc/LocationManager.java +138 -0
  29. package/android/src/main/java/com/marianhello/bgloc/PluginDelegate.java +45 -0
  30. package/android/src/main/java/com/marianhello/bgloc/PluginException.java +38 -0
  31. package/android/src/main/java/com/marianhello/bgloc/PostLocationTask.java +238 -0
  32. package/android/src/main/java/com/marianhello/bgloc/ResourceResolver.java +55 -0
  33. package/android/src/main/java/com/marianhello/bgloc/data/AbstractLocationTemplate.java +69 -0
  34. package/android/src/main/java/com/marianhello/bgloc/data/ArrayListLocationTemplate.java +88 -0
  35. package/android/src/main/java/com/marianhello/bgloc/data/BackgroundActivity.java +108 -0
  36. package/android/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +1088 -0
  37. package/android/src/main/java/com/marianhello/bgloc/data/ConfigJsonMapper.java +211 -0
  38. package/android/src/main/java/com/marianhello/bgloc/data/ConfigurationDAO.java +13 -0
  39. package/android/src/main/java/com/marianhello/bgloc/data/DAOFactory.java +17 -0
  40. package/android/src/main/java/com/marianhello/bgloc/data/HashMapLocationTemplate.java +82 -0
  41. package/android/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +27 -0
  42. package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplate.java +12 -0
  43. package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +71 -0
  44. package/android/src/main/java/com/marianhello/bgloc/data/LocationTransform.java +19 -0
  45. package/android/src/main/java/com/marianhello/bgloc/data/SessionLocationDAO.java +18 -0
  46. package/android/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +406 -0
  47. package/android/src/main/java/com/marianhello/bgloc/data/provider/LocationContentProvider.java +321 -0
  48. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +94 -0
  49. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +227 -0
  50. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +122 -0
  51. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +550 -0
  52. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +189 -0
  53. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteSessionContract.java +74 -0
  54. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteSessionLocationDAO.java +169 -0
  55. package/android/src/main/java/com/marianhello/bgloc/driving/DrivingEventsDetector.java +265 -0
  56. package/android/src/main/java/com/marianhello/bgloc/headless/AbstractTaskRunner.java +15 -0
  57. package/android/src/main/java/com/marianhello/bgloc/headless/ActivityTask.java +48 -0
  58. package/android/src/main/java/com/marianhello/bgloc/headless/JsCallback.java +10 -0
  59. package/android/src/main/java/com/marianhello/bgloc/headless/LocationTask.java +60 -0
  60. package/android/src/main/java/com/marianhello/bgloc/headless/StationaryTask.java +25 -0
  61. package/android/src/main/java/com/marianhello/bgloc/headless/Task.java +8 -0
  62. package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunner.java +5 -0
  63. package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunnerFactory.java +8 -0
  64. package/android/src/main/java/com/marianhello/bgloc/http/UrlTemplateResolver.java +115 -0
  65. package/android/src/main/java/com/marianhello/bgloc/oem/BatteryOemHelper.java +214 -0
  66. package/android/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +218 -0
  67. package/android/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +385 -0
  68. package/android/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +685 -0
  69. package/android/src/main/java/com/marianhello/bgloc/provider/LocationProvider.java +32 -0
  70. package/android/src/main/java/com/marianhello/bgloc/provider/LocationProviderFactory.java +47 -0
  71. package/android/src/main/java/com/marianhello/bgloc/provider/ProviderDelegate.java +12 -0
  72. package/android/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +175 -0
  73. package/android/src/main/java/com/marianhello/bgloc/sensor/SensorFusionDetector.java +199 -0
  74. package/android/src/main/java/com/marianhello/bgloc/service/LocationService.java +16 -0
  75. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +1531 -0
  76. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfo.java +6 -0
  77. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfoImpl.java +41 -0
  78. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java +203 -0
  79. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +156 -0
  80. package/android/src/main/java/com/marianhello/bgloc/sync/AccountHelper.java +39 -0
  81. package/android/src/main/java/com/marianhello/bgloc/sync/Authenticator.java +68 -0
  82. package/android/src/main/java/com/marianhello/bgloc/sync/AuthenticatorService.java +28 -0
  83. package/android/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +311 -0
  84. package/android/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java +148 -0
  85. package/android/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +301 -0
  86. package/android/src/main/java/com/marianhello/bgloc/sync/SyncService.java +68 -0
  87. package/android/src/main/java/com/marianhello/logging/DBLogReader.java +208 -0
  88. package/android/src/main/java/com/marianhello/logging/LogEntry.java +99 -0
  89. package/android/src/main/java/com/marianhello/logging/LoggerManager.java +70 -0
  90. package/android/src/main/java/com/marianhello/logging/UncaughtExceptionLogger.java +36 -0
  91. package/android/src/main/java/com/marianhello/utils/CloneHelper.java +22 -0
  92. package/android/src/main/java/com/marianhello/utils/Convert.java +56 -0
  93. package/android/src/main/java/com/marianhello/utils/TextUtils.java +72 -0
  94. package/android/src/main/java/com/marianhello/utils/ToneGenerator.java +68 -0
  95. package/android/src/main/java/org/apache/commons/io/Charsets.java +153 -0
  96. package/android/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +344 -0
  97. package/android/src/main/java/org/chromium/content/browser/ThreadUtils.java +134 -0
  98. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlExpression.java +398 -0
  99. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlSelectStatement.java +671 -0
  100. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlStatement.java +29 -0
  101. package/android/src/main/java/ru/andremoniy/utils/TextUtils.java +61 -0
  102. package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  103. package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  104. package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  105. package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  106. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  107. package/android/src/main/res/values/strings.xml +15 -0
  108. package/android/src/main/res/xml/authenticator.xml +7 -0
  109. package/android/src/main/res/xml/syncadapter.xml +9 -0
  110. package/dist/esm/definitions.d.ts +1052 -0
  111. package/dist/esm/definitions.js +142 -0
  112. package/dist/esm/definitions.js.map +1 -0
  113. package/dist/esm/index.d.ts +8 -0
  114. package/dist/esm/index.js +23 -0
  115. package/dist/esm/index.js.map +1 -0
  116. package/dist/esm/web.d.ts +92 -0
  117. package/dist/esm/web.js +242 -0
  118. package/dist/esm/web.js.map +1 -0
  119. package/dist/plugin.cjs.js +415 -0
  120. package/dist/plugin.cjs.js.map +1 -0
  121. package/dist/plugin.js +418 -0
  122. package/dist/plugin.js.map +1 -0
  123. package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin-Bridging-Header.h +18 -0
  124. package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.m +52 -0
  125. package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.swift +750 -0
  126. package/ios/Tests/BackgroundGeolocationPluginTests/BackgroundGeolocationPluginTests.swift +12 -0
  127. package/ios/common/BackgroundGeolocation/CocoaLumberjack.h +1945 -0
  128. package/ios/common/BackgroundGeolocation/CocoaLumberjack.m +5255 -0
  129. package/ios/common/BackgroundGeolocation/FMDB.h +2357 -0
  130. package/ios/common/BackgroundGeolocation/FMDB.m +2672 -0
  131. package/ios/common/BackgroundGeolocation/FMDBLogger.h +42 -0
  132. package/ios/common/BackgroundGeolocation/FMDBLogger.m +264 -0
  133. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.h +41 -0
  134. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.m +68 -0
  135. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager+Internal.h +33 -0
  136. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.h +178 -0
  137. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.m +1025 -0
  138. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.h +103 -0
  139. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.m +238 -0
  140. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequestDefines.h +163 -0
  141. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.h +39 -0
  142. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.m +37 -0
  143. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.h +51 -0
  144. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.m +53 -0
  145. package/ios/common/BackgroundGeolocation/MAURActivity.h +23 -0
  146. package/ios/common/BackgroundGeolocation/MAURActivity.m +52 -0
  147. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.h +18 -0
  148. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +340 -0
  149. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +88 -0
  150. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +1193 -0
  151. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +46 -0
  152. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +283 -0
  153. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.h +25 -0
  154. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.m +105 -0
  155. package/ios/common/BackgroundGeolocation/MAURConfig.h +99 -0
  156. package/ios/common/BackgroundGeolocation/MAURConfig.m +636 -0
  157. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +53 -0
  158. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +54 -0
  159. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.h +20 -0
  160. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +550 -0
  161. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.h +17 -0
  162. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +124 -0
  163. package/ios/common/BackgroundGeolocation/MAURLocation.h +73 -0
  164. package/ios/common/BackgroundGeolocation/MAURLocation.m +392 -0
  165. package/ios/common/BackgroundGeolocation/MAURLocationContract.h +38 -0
  166. package/ios/common/BackgroundGeolocation/MAURLocationContract.m +39 -0
  167. package/ios/common/BackgroundGeolocation/MAURLocationManager.h +53 -0
  168. package/ios/common/BackgroundGeolocation/MAURLocationManager.m +305 -0
  169. package/ios/common/BackgroundGeolocation/MAURLogReader.h +26 -0
  170. package/ios/common/BackgroundGeolocation/MAURLogReader.m +122 -0
  171. package/ios/common/BackgroundGeolocation/MAURLogging.h +19 -0
  172. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +53 -0
  173. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +367 -0
  174. package/ios/common/BackgroundGeolocation/MAURProviderDelegate.h +52 -0
  175. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.h +18 -0
  176. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +138 -0
  177. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.h +26 -0
  178. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +335 -0
  179. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.h +57 -0
  180. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.m +93 -0
  181. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +52 -0
  182. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +520 -0
  183. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.h +32 -0
  184. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.m +276 -0
  185. package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.h +41 -0
  186. package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.m +137 -0
  187. package/ios/common/BackgroundGeolocation/MAURSessionLocationContract.h +29 -0
  188. package/ios/common/BackgroundGeolocation/MAURSessionLocationContract.m +31 -0
  189. package/ios/common/BackgroundGeolocation/MAURSessionLocationDAO.h +25 -0
  190. package/ios/common/BackgroundGeolocation/MAURSessionLocationDAO.m +153 -0
  191. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.h +20 -0
  192. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.m +62 -0
  193. package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.h +31 -0
  194. package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.m +107 -0
  195. package/ios/common/BackgroundGeolocation/Reachability.h +102 -0
  196. package/ios/common/BackgroundGeolocation/Reachability.m +475 -0
  197. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/README.md +170 -0
  198. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.h +55 -0
  199. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.m +47 -0
  200. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlDataManipulationCommand.h +27 -0
  201. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.h +250 -0
  202. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.m +259 -0
  203. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.h +360 -0
  204. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.m +427 -0
  205. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlStatement.h +37 -0
  206. package/ios/common/BackgroundGeolocation/module.modulemap +16 -0
  207. package/package.json +82 -0
@@ -0,0 +1,103 @@
1
+ //
2
+ // INTULocationRequest.h
3
+ //
4
+ // Copyright (c) 2014-2017 Intuit Inc.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining
7
+ // a copy of this software and associated documentation files (the
8
+ // "Software"), to deal in the Software without restriction, including
9
+ // without limitation the rights to use, copy, modify, merge, publish,
10
+ // distribute, sublicense, and/or sell copies of the Software, and to
11
+ // permit persons to whom the Software is furnished to do so, subject to
12
+ // the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be
15
+ // included in all copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ //
25
+
26
+ #import "INTULocationRequestDefines.h"
27
+
28
+ NS_ASSUME_NONNULL_BEGIN
29
+
30
+ /** The available types of location requests. */
31
+ typedef NS_ENUM(NSInteger, INTULocationRequestType) {
32
+ /** A one-time location request with a specific desired accuracy and optional timeout. */
33
+ INTULocationRequestTypeSingle,
34
+ /** A subscription to location updates. */
35
+ INTULocationRequestTypeSubscription,
36
+ /** A subscription to significant location changes. */
37
+ INTULocationRequestTypeSignificantChanges
38
+ };
39
+
40
+ @class INTULocationRequest;
41
+
42
+ /**
43
+ Protocol for the INTULocationRequest to notify the its delegate that a request has timed out.
44
+ */
45
+ @protocol INTULocationRequestDelegate
46
+
47
+ /**
48
+ Notification that a location request has timed out.
49
+
50
+ @param locationRequest The location request that timed out.
51
+ */
52
+ - (void)locationRequestDidTimeout:(INTULocationRequest *)locationRequest;
53
+
54
+ @end
55
+
56
+
57
+ /**
58
+ Represents a geolocation request that is created and managed by INTULocationManager.
59
+ */
60
+ @interface INTULocationRequest : NSObject
61
+
62
+ /** The delegate for this location request. */
63
+ @property (nonatomic, weak, nullable) id<INTULocationRequestDelegate> delegate;
64
+ /** The request ID for this location request (set during initialization). */
65
+ @property (nonatomic, readonly) INTULocationRequestID requestID;
66
+ /** The type of this location request (set during initialization). */
67
+ @property (nonatomic, readonly) INTULocationRequestType type;
68
+ /** Whether this is a recurring location request (type is either Subscription or SignificantChanges). */
69
+ @property (nonatomic, readonly) BOOL isRecurring;
70
+ /** The desired accuracy for this location request. */
71
+ @property (nonatomic, assign) INTULocationAccuracy desiredAccuracy;
72
+ /** The maximum amount of time the location request should be allowed to live before completing.
73
+ If this value is exactly 0.0, it will be ignored (the request will never timeout by itself). */
74
+ @property (nonatomic, assign) NSTimeInterval timeout;
75
+ /** How long the location request has been alive since the timeout value was last set. */
76
+ @property (nonatomic, readonly) NSTimeInterval timeAlive;
77
+ /** Whether this location request has timed out (will also be YES if it has been completed). Subcriptions can never time out. */
78
+ @property (nonatomic, readonly) BOOL hasTimedOut;
79
+ /** The block to execute when the location request completes. */
80
+ @property (nonatomic, copy, nullable) INTULocationRequestBlock block;
81
+
82
+ /** Designated initializer. Initializes and returns a newly allocated location request object with the specified type. */
83
+ - (instancetype)initWithType:(INTULocationRequestType)type __INTU_DESIGNATED_INITIALIZER;
84
+
85
+ /** Completes the location request. */
86
+ - (void)complete;
87
+ /** Forces the location request to consider itself timed out. */
88
+ - (void)forceTimeout;
89
+ /** Cancels the location request. */
90
+ - (void)cancel;
91
+
92
+ /** Starts the location request's timeout timer if a nonzero timeout value is set, and the timer has not already been started. */
93
+ - (void)startTimeoutTimerIfNeeded;
94
+
95
+ /** Returns the associated recency threshold (in seconds) for the location request's desired accuracy level. */
96
+ - (NSTimeInterval)updateTimeStaleThreshold;
97
+
98
+ /** Returns the associated horizontal accuracy threshold (in meters) for the location request's desired accuracy level. */
99
+ - (CLLocationAccuracy)horizontalAccuracyThreshold;
100
+
101
+ @end
102
+
103
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,238 @@
1
+ //
2
+ // INTULocationRequest.m
3
+ //
4
+ // Copyright (c) 2014-2017 Intuit Inc.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining
7
+ // a copy of this software and associated documentation files (the
8
+ // "Software"), to deal in the Software without restriction, including
9
+ // without limitation the rights to use, copy, modify, merge, publish,
10
+ // distribute, sublicense, and/or sell copies of the Software, and to
11
+ // permit persons to whom the Software is furnished to do so, subject to
12
+ // the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be
15
+ // included in all copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ //
25
+
26
+ #import "INTULocationRequest.h"
27
+ #import "INTURequestIDGenerator.h"
28
+
29
+ @interface INTULocationRequest ()
30
+
31
+ // Redeclare this property as readwrite for internal use.
32
+ @property (nonatomic, assign, readwrite) BOOL hasTimedOut;
33
+
34
+ /** The NSDate representing the time when the request started. Set when the |timeout| property is set. */
35
+ @property (nonatomic, strong) NSDate *requestStartTime;
36
+ /** The timer that will fire to notify this request that it has timed out. Started when the |timeout| property is set. */
37
+ @property (nonatomic, strong) NSTimer *timeoutTimer;
38
+
39
+ @end
40
+
41
+
42
+ @implementation INTULocationRequest
43
+
44
+ /**
45
+ Throws an exeption when you try to create a location request using a non-designated initializer.
46
+ */
47
+ - (instancetype)init
48
+ {
49
+ @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Must use initWithType: instead." userInfo:nil];
50
+ return [self initWithType:INTULocationRequestTypeSingle];
51
+ }
52
+
53
+ /**
54
+ Designated initializer. Initializes and returns a newly allocated location request object with the specified type.
55
+
56
+ @param type The type of the location request.
57
+ */
58
+ - (instancetype)initWithType:(INTULocationRequestType)type
59
+ {
60
+ self = [super init];
61
+ if (self) {
62
+ _requestID = [INTURequestIDGenerator getUniqueRequestID];
63
+ _type = type;
64
+ _hasTimedOut = NO;
65
+ }
66
+ return self;
67
+ }
68
+
69
+ /**
70
+ Returns the associated recency threshold (in seconds) for the location request's desired accuracy level.
71
+ */
72
+ - (NSTimeInterval)updateTimeStaleThreshold
73
+ {
74
+ switch (self.desiredAccuracy) {
75
+ case INTULocationAccuracyRoom:
76
+ return kINTUUpdateTimeStaleThresholdRoom;
77
+ break;
78
+ case INTULocationAccuracyHouse:
79
+ return kINTUUpdateTimeStaleThresholdHouse;
80
+ break;
81
+ case INTULocationAccuracyBlock:
82
+ return kINTUUpdateTimeStaleThresholdBlock;
83
+ break;
84
+ case INTULocationAccuracyNeighborhood:
85
+ return kINTUUpdateTimeStaleThresholdNeighborhood;
86
+ break;
87
+ case INTULocationAccuracyCity:
88
+ return kINTUUpdateTimeStaleThresholdCity;
89
+ break;
90
+ default:
91
+ NSAssert(NO, @"Unknown desired accuracy.");
92
+ return 0.0;
93
+ break;
94
+ }
95
+ }
96
+
97
+ /**
98
+ Returns the associated horizontal accuracy threshold (in meters) for the location request's desired accuracy level.
99
+ */
100
+ - (CLLocationAccuracy)horizontalAccuracyThreshold
101
+ {
102
+ switch (self.desiredAccuracy) {
103
+ case INTULocationAccuracyRoom:
104
+ return kINTUHorizontalAccuracyThresholdRoom;
105
+ break;
106
+ case INTULocationAccuracyHouse:
107
+ return kINTUHorizontalAccuracyThresholdHouse;
108
+ break;
109
+ case INTULocationAccuracyBlock:
110
+ return kINTUHorizontalAccuracyThresholdBlock;
111
+ break;
112
+ case INTULocationAccuracyNeighborhood:
113
+ return kINTUHorizontalAccuracyThresholdNeighborhood;
114
+ break;
115
+ case INTULocationAccuracyCity:
116
+ return kINTUHorizontalAccuracyThresholdCity;
117
+ break;
118
+ default:
119
+ NSAssert(NO, @"Unknown desired accuracy.");
120
+ return 0.0;
121
+ break;
122
+ }
123
+ }
124
+
125
+ /**
126
+ Completes the location request.
127
+ */
128
+ - (void)complete
129
+ {
130
+ [self.timeoutTimer invalidate];
131
+ self.timeoutTimer = nil;
132
+ self.requestStartTime = nil;
133
+ }
134
+
135
+ /**
136
+ Forces the location request to consider itself timed out.
137
+ */
138
+ - (void)forceTimeout
139
+ {
140
+ if (self.isRecurring == NO) {
141
+ self.hasTimedOut = YES;
142
+ } else {
143
+ NSAssert(self.isRecurring == NO, @"Only single location requests (not recurring requests) should ever be considered timed out.");
144
+ }
145
+ }
146
+
147
+ /**
148
+ Cancels the location request.
149
+ */
150
+ - (void)cancel
151
+ {
152
+ [self.timeoutTimer invalidate];
153
+ self.timeoutTimer = nil;
154
+ self.requestStartTime = nil;
155
+ }
156
+
157
+ /**
158
+ Starts the location request's timeout timer if a nonzero timeout value is set, and the timer has not already been started.
159
+ */
160
+ - (void)startTimeoutTimerIfNeeded
161
+ {
162
+ if (self.timeout > 0 && !self.timeoutTimer) {
163
+ self.requestStartTime = [NSDate date];
164
+ self.timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:self.timeout target:self selector:@selector(timeoutTimerFired:) userInfo:nil repeats:NO];
165
+ }
166
+ }
167
+
168
+ /**
169
+ Computed property that returns whether this is a subscription request.
170
+ */
171
+ - (BOOL)isRecurring
172
+ {
173
+ return (self.type == INTULocationRequestTypeSubscription) || (self.type == INTULocationRequestTypeSignificantChanges);
174
+ }
175
+
176
+ /**
177
+ Computed property that returns how long the request has been alive (since the timeout value was set).
178
+ */
179
+ - (NSTimeInterval)timeAlive
180
+ {
181
+ if (self.requestStartTime == nil) {
182
+ return 0.0;
183
+ }
184
+ return fabs([self.requestStartTime timeIntervalSinceNow]);
185
+ }
186
+
187
+ /**
188
+ Returns whether the location request has timed out or not.
189
+ Once this becomes YES, it will not automatically reset to NO even if a new timeout value is set.
190
+ */
191
+ - (BOOL)hasTimedOut
192
+ {
193
+ if (self.timeout > 0.0 && self.timeAlive > self.timeout) {
194
+ _hasTimedOut = YES;
195
+ }
196
+ return _hasTimedOut;
197
+ }
198
+
199
+ /**
200
+ Callback when the timeout timer fires. Notifies the delegate that this event has occurred.
201
+ */
202
+ - (void)timeoutTimerFired:(NSTimer *)timer
203
+ {
204
+ self.hasTimedOut = YES;
205
+ [self.delegate locationRequestDidTimeout:self];
206
+ }
207
+
208
+ /**
209
+ Two location requests are considered equal if their request IDs match.
210
+ */
211
+ - (BOOL)isEqual:(id)object
212
+ {
213
+ if (object == self) {
214
+ return YES;
215
+ }
216
+ if (!object || ![object isKindOfClass:[self class]]) {
217
+ return NO;
218
+ }
219
+ if (((INTULocationRequest *)object).requestID == self.requestID) {
220
+ return YES;
221
+ }
222
+ return NO;
223
+ }
224
+
225
+ /**
226
+ Return a hash based on the string representation of the request ID.
227
+ */
228
+ - (NSUInteger)hash
229
+ {
230
+ return [[NSString stringWithFormat:@"%ld", (long)self.requestID] hash];
231
+ }
232
+
233
+ - (void)dealloc
234
+ {
235
+ [_timeoutTimer invalidate];
236
+ }
237
+
238
+ @end
@@ -0,0 +1,163 @@
1
+ //
2
+ // INTULocationRequestDefines.h
3
+ //
4
+ // Copyright (c) 2014-2017 Intuit Inc.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining
7
+ // a copy of this software and associated documentation files (the
8
+ // "Software"), to deal in the Software without restriction, including
9
+ // without limitation the rights to use, copy, modify, merge, publish,
10
+ // distribute, sublicense, and/or sell copies of the Software, and to
11
+ // permit persons to whom the Software is furnished to do so, subject to
12
+ // the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be
15
+ // included in all copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ //
25
+
26
+ #ifndef INTU_LOCATION_REQUEST_DEFINES_H
27
+ #define INTU_LOCATION_REQUEST_DEFINES_H
28
+
29
+ #import <Foundation/Foundation.h>
30
+ #import <CoreLocation/CoreLocation.h>
31
+
32
+ #if __has_feature(objc_generics)
33
+ # define __INTU_GENERICS(type, ...) type<__VA_ARGS__>
34
+ #else
35
+ # define __INTU_GENERICS(type, ...) type
36
+ #endif
37
+
38
+ #ifdef NS_DESIGNATED_INITIALIZER
39
+ # define __INTU_DESIGNATED_INITIALIZER NS_DESIGNATED_INITIALIZER
40
+ #else
41
+ # define __INTU_DESIGNATED_INITIALIZER
42
+ #endif
43
+
44
+ static const CLLocationAccuracy kINTUHorizontalAccuracyThresholdCity = 5000.0; // in meters
45
+ static const CLLocationAccuracy kINTUHorizontalAccuracyThresholdNeighborhood = 1000.0; // in meters
46
+ static const CLLocationAccuracy kINTUHorizontalAccuracyThresholdBlock = 100.0; // in meters
47
+ static const CLLocationAccuracy kINTUHorizontalAccuracyThresholdHouse = 15.0; // in meters
48
+ static const CLLocationAccuracy kINTUHorizontalAccuracyThresholdRoom = 5.0; // in meters
49
+
50
+ static const NSTimeInterval kINTUUpdateTimeStaleThresholdCity = 600.0; // in seconds
51
+ static const NSTimeInterval kINTUUpdateTimeStaleThresholdNeighborhood = 300.0; // in seconds
52
+ static const NSTimeInterval kINTUUpdateTimeStaleThresholdBlock = 60.0; // in seconds
53
+ static const NSTimeInterval kINTUUpdateTimeStaleThresholdHouse = 15.0; // in seconds
54
+ static const NSTimeInterval kINTUUpdateTimeStaleThresholdRoom = 5.0; // in seconds
55
+
56
+ /** The possible states that location services can be in. */
57
+ typedef NS_ENUM(NSInteger, INTULocationServicesState) {
58
+ /** User has already granted this app permissions to access location services, and they are enabled and ready for use by this app.
59
+ Note: this state will be returned for both the "When In Use" and "Always" permission levels. */
60
+ INTULocationServicesStateAvailable,
61
+ /** User has not yet responded to the dialog that grants this app permission to access location services. */
62
+ INTULocationServicesStateNotDetermined,
63
+ /** User has explicitly denied this app permission to access location services. (The user can enable permissions again for this app from the system Settings app.) */
64
+ INTULocationServicesStateDenied,
65
+ /** User does not have ability to enable location services (e.g. parental controls, corporate policy, etc). */
66
+ INTULocationServicesStateRestricted,
67
+ /** User has turned off location services device-wide (for all apps) from the system Settings app. */
68
+ INTULocationServicesStateDisabled
69
+ };
70
+
71
+ /** The possible states that heading services can be in. */
72
+ typedef NS_ENUM(NSInteger, INTUHeadingServicesState) {
73
+ /** Heading services are available on the device */
74
+ INTUHeadingServicesStateAvailable,
75
+ /** Heading services are available on the device */
76
+ INTUHeadingServicesStateUnavailable,
77
+ };
78
+
79
+ /** A unique ID that corresponds to one location request. */
80
+ typedef NSInteger INTULocationRequestID;
81
+
82
+ /** A unique ID that corresponds to one heading request. */
83
+ typedef NSInteger INTUHeadingRequestID;
84
+
85
+ /** An abstraction of both the horizontal accuracy and recency of location data.
86
+ Room is the highest level of accuracy/recency; City is the lowest level. */
87
+ typedef NS_ENUM(NSInteger, INTULocationAccuracy) {
88
+ // 'None' is not valid as a desired accuracy.
89
+ /** Inaccurate (>5000 meters, and/or received >10 minutes ago). */
90
+ INTULocationAccuracyNone = 0,
91
+
92
+ // The below options are valid desired accuracies.
93
+ /** 5000 meters or better, and received within the last 10 minutes. Lowest accuracy. */
94
+ INTULocationAccuracyCity,
95
+ /** 1000 meters or better, and received within the last 5 minutes. */
96
+ INTULocationAccuracyNeighborhood,
97
+ /** 100 meters or better, and received within the last 1 minute. */
98
+ INTULocationAccuracyBlock,
99
+ /** 15 meters or better, and received within the last 15 seconds. */
100
+ INTULocationAccuracyHouse,
101
+ /** 5 meters or better, and received within the last 5 seconds. Highest accuracy. */
102
+ INTULocationAccuracyRoom,
103
+ };
104
+
105
+ /** An alias of the heading filter accuracy in degrees.
106
+ Specifies the minimum amount of change in degrees needed for a heading service update. Observers will not be notified of updates less than the stated filter value. */
107
+ typedef CLLocationDegrees INTUHeadingFilterAccuracy;
108
+
109
+ /** A status that will be passed in to the completion block of a location request. */
110
+ typedef NS_ENUM(NSInteger, INTULocationStatus) {
111
+ // These statuses will accompany a valid location.
112
+ /** Got a location and desired accuracy level was achieved successfully. */
113
+ INTULocationStatusSuccess = 0,
114
+ /** Got a location, but the desired accuracy level was not reached before timeout. (Not applicable to subscriptions.) */
115
+ INTULocationStatusTimedOut,
116
+
117
+ // These statuses indicate some sort of error, and will accompany a nil location.
118
+ /** User has not yet responded to the dialog that grants this app permission to access location services. */
119
+ INTULocationStatusServicesNotDetermined,
120
+ /** User has explicitly denied this app permission to access location services. */
121
+ INTULocationStatusServicesDenied,
122
+ /** User does not have ability to enable location services (e.g. parental controls, corporate policy, etc). */
123
+ INTULocationStatusServicesRestricted,
124
+ /** User has turned off location services device-wide (for all apps) from the system Settings app. */
125
+ INTULocationStatusServicesDisabled,
126
+ /** An error occurred while using the system location services. */
127
+ INTULocationStatusError
128
+ };
129
+
130
+ /** A status that will be passed in to the completion block of a heading request. */
131
+ typedef NS_ENUM(NSInteger, INTUHeadingStatus) {
132
+ // These statuses will accompany a valid heading.
133
+ /** Got a heading successfully. */
134
+ INTUHeadingStatusSuccess = 0,
135
+
136
+ // These statuses indicate some sort of error, and will accompany a nil heading.
137
+ /** Heading was invalid. */
138
+ INTUHeadingStatusInvalid,
139
+
140
+ /** Heading services are not available on the device */
141
+ INTUHeadingStatusUnavailable
142
+ };
143
+
144
+ /**
145
+ A block type for a location request, which is executed when the request succeeds, fails, or times out.
146
+
147
+ @param currentLocation The most recent & accurate current location available when the block executes, or nil if no valid location is available.
148
+ @param achievedAccuracy The accuracy level that was actually achieved (may be better than, equal to, or worse than the desired accuracy).
149
+ @param status The status of the location request - whether it succeeded, timed out, or failed due to some sort of error. This can be used to
150
+ understand what the outcome of the request was, decide if/how to use the associated currentLocation, and determine whether other
151
+ actions are required (such as displaying an error message to the user, retrying with another request, quietly proceeding, etc).
152
+ */
153
+ typedef void(^INTULocationRequestBlock)(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status);
154
+
155
+ /**
156
+ A block type for a heading request, which is executed when the request succeeds.
157
+
158
+ @param currentHeading The most recent current heading available when the block executes.
159
+ @param status The status of the request - whether it succeeded or failed due to some sort of error. This can be used to understand if any further action is needed.
160
+ */
161
+ typedef void(^INTUHeadingRequestBlock)(CLHeading *currentHeading, INTUHeadingStatus status);
162
+
163
+ #endif /* INTU_LOCATION_REQUEST_DEFINES_H */
@@ -0,0 +1,39 @@
1
+ //
2
+ // INTURequestIDGenerator.h
3
+ //
4
+ // Copyright (c) 2014-2017 Intuit Inc.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining
7
+ // a copy of this software and associated documentation files (the
8
+ // "Software"), to deal in the Software without restriction, including
9
+ // without limitation the rights to use, copy, modify, merge, publish,
10
+ // distribute, sublicense, and/or sell copies of the Software, and to
11
+ // permit persons to whom the Software is furnished to do so, subject to
12
+ // the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be
15
+ // included in all copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ //
25
+
26
+ #import "INTULocationRequestDefines.h"
27
+
28
+ NS_ASSUME_NONNULL_BEGIN
29
+
30
+ @interface INTURequestIDGenerator : NSObject
31
+
32
+ /**
33
+ Returns a unique request ID (within the lifetime of the application).
34
+ */
35
+ +(INTULocationRequestID)getUniqueRequestID;
36
+
37
+ @end
38
+
39
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,37 @@
1
+ //
2
+ // INTURequestIDGenerator.m
3
+ //
4
+ // Copyright (c) 2014-2017 Intuit Inc.
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining
7
+ // a copy of this software and associated documentation files (the
8
+ // "Software"), to deal in the Software without restriction, including
9
+ // without limitation the rights to use, copy, modify, merge, publish,
10
+ // distribute, sublicense, and/or sell copies of the Software, and to
11
+ // permit persons to whom the Software is furnished to do so, subject to
12
+ // the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be
15
+ // included in all copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ //
25
+ #import "INTURequestIDGenerator.h"
26
+
27
+ @implementation INTURequestIDGenerator
28
+
29
+ static INTULocationRequestID _nextRequestID = 0;
30
+
31
+ +(INTULocationRequestID)getUniqueRequestID
32
+ {
33
+ _nextRequestID++;
34
+ return _nextRequestID;
35
+ }
36
+
37
+ @end
@@ -0,0 +1,51 @@
1
+ //
2
+ // MAURAbstractLocationProvider.h
3
+ // BackgroundGeolocation
4
+ //
5
+ // Created by Marian Hello on 14/09/2016.
6
+ // Copyright © 2016 mauron85. All rights reserved.
7
+ //
8
+
9
+ #ifndef MAURAbstractLocationProvider_h
10
+ #define MAURAbstractLocationProvider_h
11
+
12
+ #import <UIKit/UIKit.h>
13
+ #import <AudioToolbox/AudioToolbox.h>
14
+ #import "MAURBackgroundGeolocationFacade.h"
15
+ #import "MAURProviderDelegate.h"
16
+ #import "MAURConfig.h"
17
+
18
+ // Debug sounds for bg-geolocation life-cycle events.
19
+ // http://iphonedevwiki.net/index.php/AudioServices
20
+ #define exitRegionSound 1005
21
+ #define locationSyncSound 1004
22
+ #define paceChangeYesSound 1110
23
+ #define paceChangeNoSound 1112
24
+ #define acquiringLocationSound 1103
25
+ #define acquiredLocationSound 1052
26
+ #define locationErrorSound 1073
27
+
28
+ @protocol MAURLocationProvider <NSObject>
29
+
30
+ - (void) onCreate;
31
+ - (void) onDestroy;
32
+ - (void) onTerminate;
33
+ - (BOOL) onConfigure:(MAURConfig*)config error:(NSError * __autoreleasing *)outError;
34
+ - (BOOL) onStart:(NSError * __autoreleasing *)outError;
35
+ - (BOOL) onStop:(NSError * __autoreleasing *)outError;
36
+ - (void) onSwitchMode:(MAUROperationalMode)mode;
37
+
38
+ @end
39
+
40
+ @interface MAURAbstractLocationProvider : NSObject//<LocationProvider>
41
+
42
+ @property (weak, nonatomic) id<MAURProviderDelegate> delegate;
43
+
44
+ - (void) onTerminate;
45
+ - (void) onSwitchMode:(MAUROperationalMode)mode;
46
+ - (void) notify:(NSString*)message;
47
+
48
+ @end
49
+
50
+
51
+ #endif /* MAURAbstractLocationProvider_h */
@@ -0,0 +1,53 @@
1
+ //
2
+ // MAURAbstractLocationProvider.m
3
+ // BackgroundGeolocation
4
+ //
5
+ // Created by Marian Hello on 14/09/2016.
6
+ // Copyright © 2016 mauron85. All rights reserved.
7
+ //
8
+
9
+ #import "MAURAbstractLocationProvider.h"
10
+
11
+ @implementation MAURAbstractLocationProvider {
12
+ UILocalNotification *localNotification;
13
+ }
14
+
15
+ @synthesize delegate;
16
+
17
+ - (instancetype) init
18
+ {
19
+ if( [self class] == [MAURAbstractLocationProvider class])
20
+ {
21
+ NSAssert(false, @"You cannot init this class directly. Instead, use a subclass e.g. DistanceFilterLocationProvider.h");
22
+ return nil;
23
+ }
24
+
25
+ self = [super init];
26
+ if (self == nil) {
27
+ return self;
28
+ }
29
+
30
+ localNotification = [[UILocalNotification alloc] init];
31
+ localNotification.timeZone = [NSTimeZone defaultTimeZone];
32
+
33
+ return self;
34
+ }
35
+
36
+ - (void) notify:(NSString*)message
37
+ {
38
+ localNotification.fireDate = [NSDate date];
39
+ localNotification.alertBody = message;
40
+ [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
41
+ }
42
+
43
+ - (void) onTerminate
44
+ {
45
+ // override in sub class
46
+ }
47
+
48
+ - (void) onSwitchMode:(MAUROperationalMode)mode
49
+ {
50
+ // override in sub class
51
+ }
52
+
53
+ @end