@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,1052 @@
1
+ import type { PermissionState, PluginListenerHandle } from '@capacitor/core';
2
+ /**
3
+ * Location provider strategy. Strings are preferred in the Capacitor API.
4
+ * Numeric ids `0 | 1 | 2` are accepted for back-compat with the Cordova plugin.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+ export type LocationProvider = 'DISTANCE_FILTER' | 'ACTIVITY_PROVIDER' | 'RAW_PROVIDER' | 0 | 1 | 2;
9
+ /**
10
+ * Numeric mapping of {@link LocationProvider} matching the Cordova plugin.
11
+ *
12
+ * @since 1.0.0
13
+ */
14
+ export declare const LocationProviderValue: {
15
+ readonly DISTANCE_FILTER: 0;
16
+ readonly ACTIVITY_PROVIDER: 1;
17
+ readonly RAW_PROVIDER: 2;
18
+ };
19
+ /**
20
+ * Desired accuracy. Strings or the corresponding meters value (`0 | 100 | 1000 | 10000`).
21
+ *
22
+ * @since 1.0.0
23
+ */
24
+ export type Accuracy = 'HIGH' | 'MEDIUM' | 'LOW' | 'PASSIVE' | number;
25
+ /**
26
+ * Meters mapping of {@link Accuracy} (matches the Cordova plugin's `AccuracyLevel`).
27
+ *
28
+ * @since 1.0.0
29
+ */
30
+ export declare const AccuracyValue: {
31
+ readonly HIGH: 0;
32
+ readonly MEDIUM: 100;
33
+ readonly LOW: 1000;
34
+ readonly PASSIVE: 10000;
35
+ };
36
+ /**
37
+ * Hex string (e.g. `'#4CAF50'`) used for the Android notification accent color.
38
+ *
39
+ * @since 1.0.0
40
+ */
41
+ export type NotificationIconColor = string;
42
+ /**
43
+ * Service authorization state, mirroring the Cordova plugin constants.
44
+ *
45
+ * @since 1.0.0
46
+ */
47
+ export declare enum AuthorizationStatus {
48
+ NOT_AUTHORIZED = 0,
49
+ AUTHORIZED = 1,
50
+ AUTHORIZED_FOREGROUND = 2
51
+ }
52
+ /**
53
+ * Log levels accepted by {@link BackgroundGeolocationPlugin.getLogEntries}.
54
+ *
55
+ * @since 1.0.0
56
+ */
57
+ export type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
58
+ /**
59
+ * Native location source reported by the OS.
60
+ *
61
+ * @since 1.0.0
62
+ */
63
+ export type NativeProvider = 'gps' | 'network' | 'passive' | 'fused';
64
+ /**
65
+ * iOS `CLActivityType` mapping.
66
+ *
67
+ * @since 1.0.0
68
+ */
69
+ export type IOSActivityType = 'AutomotiveNavigation' | 'OtherNavigation' | 'Fitness' | 'Other';
70
+ /**
71
+ * Service mode used by {@link BackgroundGeolocationPlugin.switchMode}.
72
+ * `0 = BACKGROUND`, `1 = FOREGROUND`.
73
+ *
74
+ * @since 1.0.0
75
+ */
76
+ export type ServiceMode = 0 | 1;
77
+ /**
78
+ * Activity type reported by the activity-recognition provider.
79
+ *
80
+ * @since 1.0.0
81
+ */
82
+ export type ActivityType = 'IN_VEHICLE' | 'ON_BICYCLE' | 'ON_FOOT' | 'RUNNING' | 'STILL' | 'TILTING' | 'UNKNOWN' | 'WALKING';
83
+ /**
84
+ * Numeric error code emitted with `LocationError`.
85
+ * - `1` PERMISSION_DENIED
86
+ * - `2` LOCATION_UNAVAILABLE
87
+ * - `3` TIMEOUT
88
+ *
89
+ * @since 1.0.0
90
+ */
91
+ export type LocationErrorCode = 1 | 2 | 3;
92
+ /**
93
+ * Headless task event name. Reserved for a future `BackgroundFetch`-style hook.
94
+ *
95
+ * @since 1.0.0
96
+ */
97
+ export type HeadlessTaskEventName = 'location' | 'stationary' | 'activity';
98
+ /**
99
+ * Plugin configuration options. Fields mirror the Cordova plugin's
100
+ * `ConfigureOptions` 1:1. Every field is optional; the native side uses safe
101
+ * defaults documented inline.
102
+ *
103
+ * @since 1.0.0
104
+ */
105
+ export interface ConfigureOptions {
106
+ /** Location provider strategy. @default 'DISTANCE_FILTER' */
107
+ locationProvider?: LocationProvider;
108
+ /** Desired accuracy in meters. @default 'MEDIUM' */
109
+ desiredAccuracy?: Accuracy;
110
+ /** Stationary radius in meters. @default 50 */
111
+ stationaryRadius?: number;
112
+ /** Emit debugging sounds for life-cycle events. @default false */
113
+ debug?: boolean;
114
+ /** Minimum horizontal distance (meters) between location updates. @default 500 */
115
+ distanceFilter?: number;
116
+ /** Stop tracking when the app is terminated. @default true */
117
+ stopOnTerminate?: boolean;
118
+ /** Start tracking on device boot. Android. @default false */
119
+ startOnBoot?: boolean;
120
+ /** Minimum time interval between location updates (ms). Android. @default 600000 */
121
+ interval?: number;
122
+ /** Fastest rate (ms) at which updates may be delivered. Android. @default 120000 */
123
+ fastestInterval?: number;
124
+ /** Activity recognition cadence (ms). Android ACTIVITY provider. @default 10000 */
125
+ activitiesInterval?: number;
126
+ /** @deprecated Stop on STILL activity. */
127
+ stopOnStillActivity?: boolean;
128
+ /** Restart the provider if no update is received for ~60s. Android. @default false */
129
+ enableWatchdog?: boolean;
130
+ /** Show local notifications during tracking/sync. Android. @default true */
131
+ notificationsEnabled?: boolean;
132
+ /** Run the sync service in foreground (Android requires a notification). @default false */
133
+ startForeground?: boolean;
134
+ /** Foreground notification title. @default 'Background tracking' */
135
+ notificationTitle?: string;
136
+ /** Foreground notification body. @default 'ENABLED' */
137
+ notificationText?: string;
138
+ /** Show elapsed time in the notification. Android. @default false */
139
+ showTime?: boolean;
140
+ /** Show accumulated distance in the notification. Android. @default false */
141
+ showDistance?: boolean;
142
+ /** Sync notification title. Android. @default 'Syncing locations' */
143
+ notificationSyncTitle?: string;
144
+ /** Sync notification body. @default 'Sync in progress' */
145
+ notificationSyncText?: string;
146
+ /** Sync notification body on success. @default 'Sync completed' */
147
+ notificationSyncCompletedText?: string;
148
+ /** Sync notification body on failure. @default 'Sync failed' */
149
+ notificationSyncFailedText?: string;
150
+ /** Notification accent color (`#RRGGBB`). Android. */
151
+ notificationIconColor?: NotificationIconColor;
152
+ /** Custom large notification icon (drawable name). Android. */
153
+ notificationIconLarge?: string;
154
+ /** Custom small notification icon (drawable name). Android. */
155
+ notificationIconSmall?: string;
156
+ /** iOS activity type hint. @default 'OtherNavigation' */
157
+ activityType?: IOSActivityType;
158
+ /** Allow iOS to pause location updates. @default false */
159
+ pauseLocationUpdates?: boolean;
160
+ /** iOS: switch to significant changes in background. @default false */
161
+ saveBatteryOnBackground?: boolean;
162
+ /** Endpoint where each location is POSTed. */
163
+ url?: string;
164
+ /** Endpoint used by the sync queue for failed locations. */
165
+ syncUrl?: string;
166
+ /** Sync batch size. @default 100 */
167
+ syncThreshold?: number;
168
+ /** Whether automatic sync to {@link syncUrl} is enabled. @default true */
169
+ sync?: boolean;
170
+ /** HTTP headers added to every request. */
171
+ httpHeaders?: {
172
+ [key: string]: string;
173
+ };
174
+ /** Alias of {@link httpHeaders} (v3.3 backend-agnostic transport). */
175
+ headers?: {
176
+ [key: string]: string;
177
+ };
178
+ /** HTTP method for `url`. @default 'POST' */
179
+ httpMethod?: 'POST' | 'GET' | 'PUT' | 'PATCH';
180
+ /** HTTP method for `syncUrl`. @default 'POST' */
181
+ syncHttpMethod?: 'POST' | 'GET' | 'PUT' | 'PATCH';
182
+ /** Delivery mode for real-time locations. @default 'batch' */
183
+ httpMode?: 'batch' | 'single';
184
+ /** Delivery mode for sync-queue locations. @default 'batch' */
185
+ syncMode?: 'batch' | 'single';
186
+ /** Placeholder values used by URL/body templating. */
187
+ queryParams?: {
188
+ [key: string]: string | number;
189
+ };
190
+ /** Maximum locations stored in the local DB. @default 10000 */
191
+ maxLocations?: number;
192
+ /** Body template applied to each location. */
193
+ postTemplate?: unknown;
194
+ /** Alias of {@link postTemplate}. */
195
+ bodyTemplate?: unknown;
196
+ /** iOS 11+: show the blue background-location indicator. @default false */
197
+ showsBackgroundLocationIndicator?: boolean;
198
+ /** Heartbeat tick interval (ms). 0 disables. @default 0 */
199
+ heartbeatInterval?: number;
200
+ /** Policy for samples flagged as mock locations. @default 'allow' */
201
+ mockLocationPolicy?: 'allow' | 'flag' | 'drop';
202
+ /** Stamp battery level / charging state on every fix. @default true */
203
+ includeBattery?: boolean;
204
+ /** Android WakeLock policy. @default 'posting' */
205
+ wakeLockMode?: 'none' | 'posting' | 'always';
206
+ /** Stationary detection: no-movement time (ms). Android. @default 300000 */
207
+ stationaryTimeout?: number;
208
+ /** Stationary detection: lazy poll (ms). Android. @default 180000 */
209
+ stationaryPollInterval?: number;
210
+ /** Stationary detection: aggressive poll (ms). Android. @default 60000 */
211
+ stationaryPollFast?: number;
212
+ /** Activity confidence threshold (0–100). @default 50 */
213
+ activityConfidenceThreshold?: number;
214
+ /** Drop fixes whose reported accuracy is worse than this (meters). */
215
+ maxAcceptedAccuracy?: number;
216
+ /** Driver-insights state machine configuration. */
217
+ drivingEvents?: {
218
+ /** Master switch. When `false` (default) no driver-insight events are emitted. */
219
+ enabled?: boolean;
220
+ /** Speed limit (km/h) for the `speeding` event. `0` disables. */
221
+ speedLimit?: number;
222
+ /** m/s threshold below which the user is considered stopped. */
223
+ minMovingSpeed?: number;
224
+ /** ms of continuous below-threshold speed needed to confirm `stopped`. */
225
+ stoppedDuration?: number;
226
+ /** m/s threshold to start counting a trip. */
227
+ minTripSpeed?: number;
228
+ /** ms of continuous above-threshold speed needed to confirm `tripStart`. */
229
+ minTripDuration?: number;
230
+ /** Deceleration threshold (m/s²) for `hardBrake`. */
231
+ hardBrakeMps2?: number;
232
+ /** Acceleration threshold (m/s²) for `rapidAcceleration`. */
233
+ rapidAccelMps2?: number;
234
+ /** Bearing change rate (deg/s) for `sharpTurn`. */
235
+ sharpTurnDegPerSec?: number;
236
+ /** Velocity drop (km/h) within `crashWindowMs` to trigger `possibleCrash`. */
237
+ crashImpactKmh?: number;
238
+ /** Window (ms) used to evaluate the crash impact. */
239
+ crashWindowMs?: number;
240
+ /** Enable accelerometer/gyroscope sensor fusion. @default false */
241
+ sensorFusion?: boolean;
242
+ /** Crash impact threshold in g for the sensor pipeline. */
243
+ crashImpactG?: number;
244
+ /** Cooldown (ms) between sensor-driven crash detections. */
245
+ sensorCrashCooldownMs?: number;
246
+ /** Sustained jitter window (ms) for `phoneUsageWhileDriving`. */
247
+ phoneUsageWindowMs?: number;
248
+ /** Cooldown (ms) between `phoneUsageWhileDriving` events. */
249
+ phoneUsageCooldownMs?: number;
250
+ };
251
+ /** Forward-compatible escape hatch for new native options. */
252
+ [extra: string]: unknown;
253
+ }
254
+ /**
255
+ * Backwards-compatible alias for {@link ConfigureOptions} (v0.x name).
256
+ *
257
+ * @since 1.0.0
258
+ */
259
+ export type LocationOptions = ConfigureOptions;
260
+ /** Options for {@link BackgroundGeolocationPlugin.getCurrentLocation}. @since 1.0.0 */
261
+ export interface CurrentLocationOptions {
262
+ /** Max time the device will wait for a fix (ms). */
263
+ timeout?: number;
264
+ /** Max age of a cached fix that is acceptable (ms). */
265
+ maximumAge?: number;
266
+ /** Request the most accurate position available. */
267
+ enableHighAccuracy?: boolean;
268
+ }
269
+ /**
270
+ * A single location fix delivered by the native provider.
271
+ *
272
+ * @since 1.0.0
273
+ */
274
+ export interface Location {
275
+ /** DB id (`null`/`undefined` for synthetic fixes). */
276
+ id: number;
277
+ /** Native provider. */
278
+ provider: NativeProvider;
279
+ /** Configured location provider id. */
280
+ locationProvider: number;
281
+ /** UTC timestamp in ms. */
282
+ time: number;
283
+ /** Latitude in degrees. */
284
+ latitude: number;
285
+ /** Longitude in degrees. */
286
+ longitude: number;
287
+ /** Horizontal accuracy in meters. */
288
+ accuracy: number;
289
+ /** Ground speed in m/s. */
290
+ speed: number;
291
+ /** Altitude in meters. */
292
+ altitude: number;
293
+ /** Bearing in degrees. */
294
+ bearing: number;
295
+ /** Android: fix came from a mock provider. */
296
+ isFromMockProvider?: boolean;
297
+ /** Android: developer-options "mock locations" is enabled. */
298
+ mockLocationsEnabled?: boolean;
299
+ /** iOS 15+: simulator-generated fix. */
300
+ simulated?: boolean;
301
+ /** Driving events anchored to this fix. */
302
+ events?: Array<{
303
+ type: string;
304
+ time: number;
305
+ [key: string]: unknown;
306
+ }>;
307
+ /** Battery percentage (0–100) when {@link ConfigureOptions.includeBattery} is on. */
308
+ battery?: number;
309
+ /** Charging state when {@link ConfigureOptions.includeBattery} is on. */
310
+ isCharging?: boolean;
311
+ }
312
+ /** Stationary location adds a `radius` (meters) to {@link Location}. @since 1.0.0 */
313
+ export interface StationaryLocation extends Location {
314
+ /** Stationary radius in meters. */
315
+ radius: number;
316
+ }
317
+ /** Geolocation error shape. @since 1.0.0 */
318
+ export interface LocationError {
319
+ /** Reason code. */
320
+ code: LocationErrorCode;
321
+ /** Human-readable description. */
322
+ message: string;
323
+ }
324
+ /** Generic native plugin error. @since 1.0.0 */
325
+ export interface BackgroundGeolocationError {
326
+ /** Numeric error code. */
327
+ code: number;
328
+ /** Human-readable description. */
329
+ message: string;
330
+ }
331
+ /** Activity recognition payload. @since 1.0.0 */
332
+ export interface Activity {
333
+ /** Recognised activity type. */
334
+ type: ActivityType;
335
+ /** Confidence percentage (0–100). */
336
+ confidence: number;
337
+ }
338
+ /** Service status returned by {@link BackgroundGeolocationPlugin.checkStatus}. @since 1.0.0 */
339
+ export interface ServiceStatus {
340
+ /** Service is currently running. */
341
+ isRunning: boolean;
342
+ /** OS-level location services are enabled. */
343
+ locationServicesEnabled: boolean;
344
+ /** Current authorization state. */
345
+ authorization: AuthorizationStatus;
346
+ }
347
+ /** Backwards-compatible alias for {@link ServiceStatus}. @since 1.0.0 */
348
+ export type Status = ServiceStatus;
349
+ /**
350
+ * Extended diagnostics returned by {@link BackgroundGeolocationPlugin.getDiagnostics}.
351
+ *
352
+ * @since 1.0.0
353
+ */
354
+ export interface Diagnostics {
355
+ /** TRUE if the native service is currently running. */
356
+ isRunning: boolean;
357
+ /** TRUE if the OS-level location services are enabled. */
358
+ locationServicesEnabled: boolean;
359
+ /** Configured `startOnBoot` flag. */
360
+ startOnBoot?: boolean;
361
+ /** Number of locations queued for sync. */
362
+ pendingSyncCount?: number;
363
+ /** UTC ms of the last received location, or `null` if none yet. */
364
+ lastLocationAt?: number | null;
365
+ /** Android: TRUE if `ACCESS_FINE_LOCATION` is granted. */
366
+ fineLocationGranted?: boolean;
367
+ /** Android: TRUE if `ACCESS_COARSE_LOCATION` is granted. */
368
+ coarseLocationGranted?: boolean;
369
+ /** Android 10+: TRUE if `ACCESS_BACKGROUND_LOCATION` is granted. */
370
+ backgroundLocationGranted?: boolean;
371
+ /** Android 13+: TRUE if `POST_NOTIFICATIONS` is granted. */
372
+ notificationPermissionGranted?: boolean;
373
+ /** Android 10+: TRUE if `ACTIVITY_RECOGNITION` is granted. */
374
+ activityRecognitionGranted?: boolean;
375
+ /** Android: TRUE if the app is on the battery optimisation whitelist. */
376
+ batteryOptimizationIgnored?: boolean;
377
+ /** Android: device manufacturer (`Build.MANUFACTURER`). */
378
+ manufacturer?: string;
379
+ /** Android: declared `foregroundServiceType` (numeric). */
380
+ foregroundServiceType?: number;
381
+ /** iOS 14+: TRUE if the user granted Precise Location. */
382
+ preciseLocationEnabled?: boolean;
383
+ /** iOS: status of system-wide Background App Refresh. */
384
+ backgroundRefreshStatus?: 'available' | 'denied' | 'restricted';
385
+ /** iOS: TRUE if Low Power Mode is currently enabled. */
386
+ lowPowerModeEnabled?: boolean;
387
+ /** iOS: status of the Motion & Fitness permission. */
388
+ motionPermissionStatus?: 'authorized' | 'denied' | 'restricted' | 'notDetermined';
389
+ /** iOS: human-readable label of the current `CLAuthorizationStatus`. */
390
+ authorizationStatusText?: string;
391
+ }
392
+ /** Persisted log entry returned by {@link BackgroundGeolocationPlugin.getLogEntries}. @since 1.0.0 */
393
+ export interface LogEntry {
394
+ /** DB id. */
395
+ id: number;
396
+ /** UTC timestamp (ms). */
397
+ timestamp: number;
398
+ /** Severity. */
399
+ level: LogLevel;
400
+ /** Message body. */
401
+ message: string;
402
+ /** Stack trace (Android only — iOS folds it into `message`). */
403
+ stackTrace: string;
404
+ }
405
+ /**
406
+ * Headless task event payload (reserved for a future v1.1 hook).
407
+ *
408
+ * @since 1.0.0
409
+ */
410
+ export interface HeadlessTaskEvent {
411
+ /** Event name. */
412
+ name: HeadlessTaskEventName;
413
+ /** Event parameters. */
414
+ params: unknown;
415
+ }
416
+ /** iOS background task handle returned by {@link BackgroundGeolocationPlugin.startTask}. @since 1.0.0 */
417
+ export interface Task {
418
+ /** Native task identifier — pass back to `endTask`. */
419
+ taskKey: number;
420
+ }
421
+ /** Result of an Android runtime permission request. @since 1.0.0 */
422
+ export interface PermissionRequestResult {
423
+ /** TRUE if all requested permissions were granted. */
424
+ granted: boolean;
425
+ /** Names of any permissions that were denied. */
426
+ denied?: string[];
427
+ /** TRUE when the OS version made the request a no-op (e.g. iOS, old Android). */
428
+ notRequired?: boolean;
429
+ }
430
+ /**
431
+ * Public contract of the `BackgroundGeolocation` plugin.
432
+ *
433
+ * @since 1.0.0
434
+ */
435
+ export interface BackgroundGeolocationPlugin {
436
+ /**
437
+ * Configure the native plugin. Must be called at least once before `start`.
438
+ *
439
+ * @since 1.0.0
440
+ */
441
+ configure(options: ConfigureOptions): Promise<void>;
442
+ /**
443
+ * Start the native background location service.
444
+ *
445
+ * @since 1.0.0
446
+ */
447
+ start(): Promise<void>;
448
+ /**
449
+ * Stop the native background location service.
450
+ *
451
+ * @since 1.0.0
452
+ */
453
+ stop(): Promise<void>;
454
+ /**
455
+ * Switch plugin operation mode (iOS).
456
+ * `0` = BACKGROUND, `1` = FOREGROUND.
457
+ *
458
+ * @since 1.0.0
459
+ */
460
+ switchMode(options: {
461
+ mode: ServiceMode;
462
+ }): Promise<void>;
463
+ /**
464
+ * Service status snapshot.
465
+ *
466
+ * @since 1.0.0
467
+ */
468
+ checkStatus(): Promise<ServiceStatus>;
469
+ /**
470
+ * One-shot location request.
471
+ *
472
+ * @since 1.0.0
473
+ */
474
+ getCurrentLocation(options?: CurrentLocationOptions): Promise<Location>;
475
+ /**
476
+ * Returns the last stationary location if any, otherwise `null`.
477
+ *
478
+ * @since 1.0.0
479
+ */
480
+ getStationaryLocation(): Promise<StationaryLocation | null>;
481
+ /**
482
+ * Return all stored locations.
483
+ *
484
+ * @since 1.0.0
485
+ */
486
+ getLocations(): Promise<{
487
+ locations: Location[];
488
+ }>;
489
+ /**
490
+ * Locations stored locally that have not yet been delivered.
491
+ *
492
+ * @since 1.0.0
493
+ */
494
+ getValidLocations(): Promise<{
495
+ locations: Location[];
496
+ }>;
497
+ /**
498
+ * Like {@link getValidLocations} but also deletes the rows returned.
499
+ *
500
+ * @since 1.0.0
501
+ */
502
+ getValidLocationsAndDelete(): Promise<{
503
+ locations: Location[];
504
+ }>;
505
+ /**
506
+ * Delete a single stored location by DB id.
507
+ *
508
+ * @since 1.0.0
509
+ */
510
+ deleteLocation(options: {
511
+ locationId: number;
512
+ }): Promise<void>;
513
+ /**
514
+ * Delete every stored location.
515
+ *
516
+ * @since 1.0.0
517
+ */
518
+ deleteAllLocations(): Promise<void>;
519
+ /**
520
+ * Force an immediate sync of pending locations to `syncUrl`.
521
+ *
522
+ * @since 1.0.0
523
+ */
524
+ forceSync(): Promise<void>;
525
+ /**
526
+ * Discard every pending sync-queue location.
527
+ *
528
+ * @since 1.0.0
529
+ */
530
+ clearSync(): Promise<void>;
531
+ /**
532
+ * Number of locations pending to be synced.
533
+ *
534
+ * @since 1.0.0
535
+ */
536
+ getPendingSyncCount(): Promise<{
537
+ count: number;
538
+ }>;
539
+ /**
540
+ * Begin a recording session (clears the session table and starts collecting).
541
+ *
542
+ * @since 1.0.0
543
+ */
544
+ startSession(): Promise<void>;
545
+ /**
546
+ * Return every location stored in the current session.
547
+ *
548
+ * @since 1.0.0
549
+ */
550
+ getSessionLocations(): Promise<{
551
+ locations: Location[];
552
+ }>;
553
+ /**
554
+ * Clear the session table and stop collecting.
555
+ *
556
+ * @since 1.0.0
557
+ */
558
+ clearSession(): Promise<void>;
559
+ /**
560
+ * Count of locations in the current session.
561
+ *
562
+ * @since 1.0.0
563
+ */
564
+ getSessionLocationsCount(): Promise<{
565
+ count: number;
566
+ }>;
567
+ /**
568
+ * Extended diagnostics (permissions, battery optimisation, OEM, iOS flags).
569
+ *
570
+ * @since 1.0.0
571
+ */
572
+ getDiagnostics(): Promise<Diagnostics>;
573
+ /**
574
+ * Android: TRUE if the app is on the battery optimisation whitelist.
575
+ * iOS: resolves `{ whitelisted: true }`.
576
+ *
577
+ * @since 1.0.0
578
+ */
579
+ isIgnoringBatteryOptimizations(): Promise<{
580
+ whitelisted: boolean;
581
+ }>;
582
+ /**
583
+ * Android: prompt the user to add the app to the battery optimisation whitelist.
584
+ * iOS: resolves `{ whitelisted: true }`.
585
+ *
586
+ * @since 1.0.0
587
+ */
588
+ requestIgnoreBatteryOptimizations(): Promise<{
589
+ whitelisted: boolean;
590
+ }>;
591
+ /**
592
+ * Android: open the battery-related settings screen.
593
+ * iOS: no-op.
594
+ *
595
+ * @since 1.0.0
596
+ */
597
+ openBatterySettings(): Promise<void>;
598
+ /**
599
+ * Android: open the OEM-specific auto-start / background-activity screen.
600
+ *
601
+ * @since 1.0.0
602
+ */
603
+ openAutoStartSettings(): Promise<{
604
+ opened: boolean;
605
+ manufacturer: string;
606
+ screen: string;
607
+ }>;
608
+ /**
609
+ * Return OEM-specific guidance steps to surface in the UI.
610
+ *
611
+ * @since 1.0.0
612
+ */
613
+ getManufacturerHelp(): Promise<{
614
+ manufacturer: string;
615
+ steps: string[];
616
+ }>;
617
+ /**
618
+ * Get the plugin version from native code.
619
+ *
620
+ * @since 1.0.0
621
+ */
622
+ getPluginVersion(): Promise<{
623
+ version: string;
624
+ }>;
625
+ /**
626
+ * Capacitor-style permission check. Resolves to the current location permission.
627
+ *
628
+ * @since 1.0.0
629
+ */
630
+ checkPermissions(): Promise<{
631
+ location: PermissionState;
632
+ }>;
633
+ /**
634
+ * Capacitor-style permission request. Prompts the user if needed.
635
+ *
636
+ * @since 1.0.0
637
+ */
638
+ requestPermissions(): Promise<{
639
+ location: PermissionState;
640
+ }>;
641
+ /**
642
+ * Request `ACCESS_BACKGROUND_LOCATION` (Android 10+).
643
+ *
644
+ * @since 1.0.0
645
+ */
646
+ requestBackgroundLocationPermission(): Promise<PermissionRequestResult>;
647
+ /**
648
+ * Request `ACTIVITY_RECOGNITION` (Android 10+).
649
+ *
650
+ * @since 1.0.0
651
+ */
652
+ requestActivityRecognitionPermission(): Promise<PermissionRequestResult>;
653
+ /**
654
+ * Request `POST_NOTIFICATIONS` (Android 13+).
655
+ *
656
+ * @since 1.0.0
657
+ */
658
+ requestNotificationPermission(): Promise<PermissionRequestResult>;
659
+ /**
660
+ * Open this app's settings screen so the user can change permissions.
661
+ *
662
+ * @since 1.0.0
663
+ */
664
+ showAppSettings(): Promise<void>;
665
+ /**
666
+ * Convenience alias for {@link showAppSettings}.
667
+ *
668
+ * @since 1.0.0
669
+ */
670
+ openSettings(): Promise<void>;
671
+ /**
672
+ * Open the system Location settings screen (Android).
673
+ *
674
+ * @since 1.0.0
675
+ */
676
+ showLocationSettings(): Promise<void>;
677
+ /**
678
+ * iOS: begin a background task. Pair every call with {@link endTask}.
679
+ *
680
+ * @since 1.0.0
681
+ */
682
+ startTask(): Promise<{
683
+ taskKey: number;
684
+ }>;
685
+ /**
686
+ * iOS: end a background task started by {@link startTask}.
687
+ *
688
+ * @since 1.0.0
689
+ */
690
+ endTask(options: {
691
+ taskKey: number;
692
+ }): Promise<void>;
693
+ /**
694
+ * Trigger an SOS event from JS. The plugin emits an `sos` event carrying
695
+ * the latest known location plus the user-supplied payload.
696
+ *
697
+ * @since 1.0.0
698
+ */
699
+ triggerSOS(payload?: Record<string, unknown>): Promise<void>;
700
+ /**
701
+ * Retrieve the persisted configuration.
702
+ *
703
+ * @since 1.0.0
704
+ */
705
+ getConfig(): Promise<ConfigureOptions>;
706
+ /**
707
+ * Return logged plugin events (useful for diagnostics).
708
+ *
709
+ * @since 1.0.0
710
+ */
711
+ getLogEntries(options: {
712
+ /** Maximum entries to return. */
713
+ limit: number;
714
+ /** Only entries with `id > fromId`. */
715
+ fromId?: number;
716
+ /** Minimum severity to include. */
717
+ minLevel?: LogLevel;
718
+ }): Promise<{
719
+ entries: LogEntry[];
720
+ }>;
721
+ /**
722
+ * **Android only.** Register a JS callback that runs on `location`,
723
+ * `stationary`, and `activity` events even when the host activity has
724
+ * been killed by the system — as long as `stopOnTerminate: false` and
725
+ * the foreground service is still alive.
726
+ *
727
+ * The function body is serialised with `task.toString()` and evaluated
728
+ * inside a hidden Android WebView via the upstream `JsEvaluator`
729
+ * pipeline. Variables from the outer scope CANNOT be referenced — the
730
+ * callback runs in an isolated context. Plain `XMLHttpRequest`,
731
+ * `fetch`, and `JSON` are available.
732
+ *
733
+ * On iOS this call resolves immediately as a no-op (Apple does not
734
+ * allow running JS in a killed-app scenario). On Web it throws
735
+ * `unimplemented`. Prefer the regular `addListener` flow whenever
736
+ * possible — `headlessTask` is only useful when the app has been
737
+ * killed by the OS but the service must still react to GPS events.
738
+ *
739
+ * @since 1.0.0
740
+ */
741
+ headlessTask(task: (event: HeadlessTaskEvent) => unknown): Promise<void>;
742
+ /**
743
+ * Remove every registered listener attached to this plugin instance.
744
+ *
745
+ * @since 1.0.0
746
+ */
747
+ removeAllListeners(): Promise<void>;
748
+ /**
749
+ * New location fix.
750
+ *
751
+ * @since 1.0.0
752
+ */
753
+ addListener(eventName: 'location', listener: (event: Location) => void): Promise<PluginListenerHandle>;
754
+ /**
755
+ * Stationary state entered.
756
+ *
757
+ * @since 1.0.0
758
+ */
759
+ addListener(eventName: 'stationary', listener: (event: StationaryLocation) => void): Promise<PluginListenerHandle>;
760
+ /**
761
+ * Activity recognition update.
762
+ *
763
+ * @since 1.0.0
764
+ */
765
+ addListener(eventName: 'activity', listener: (event: Activity) => void): Promise<PluginListenerHandle>;
766
+ /**
767
+ * Service started.
768
+ *
769
+ * @since 1.0.0
770
+ */
771
+ addListener(eventName: 'start', listener: () => void): Promise<PluginListenerHandle>;
772
+ /**
773
+ * Service stopped.
774
+ *
775
+ * @since 1.0.0
776
+ */
777
+ addListener(eventName: 'stop', listener: () => void): Promise<PluginListenerHandle>;
778
+ /**
779
+ * Recoverable or fatal native error.
780
+ *
781
+ * @since 1.0.0
782
+ */
783
+ addListener(eventName: 'error', listener: (event: BackgroundGeolocationError) => void): Promise<PluginListenerHandle>;
784
+ /**
785
+ * User changed authorization or toggled location services.
786
+ *
787
+ * @since 1.0.0
788
+ */
789
+ addListener(eventName: 'authorization', listener: (event: {
790
+ status: AuthorizationStatus;
791
+ }) => void): Promise<PluginListenerHandle>;
792
+ /**
793
+ * App entered the foreground.
794
+ *
795
+ * @since 1.0.0
796
+ */
797
+ addListener(eventName: 'foreground', listener: () => void): Promise<PluginListenerHandle>;
798
+ /**
799
+ * App entered the background.
800
+ *
801
+ * @since 1.0.0
802
+ */
803
+ addListener(eventName: 'background', listener: () => void): Promise<PluginListenerHandle>;
804
+ /**
805
+ * Server returned `285 Updates Not Required`.
806
+ *
807
+ * @since 1.0.0
808
+ */
809
+ addListener(eventName: 'abort_requested', listener: () => void): Promise<PluginListenerHandle>;
810
+ /**
811
+ * Server returned `401 Unauthorized`.
812
+ *
813
+ * @since 1.0.0
814
+ */
815
+ addListener(eventName: 'http_authorization', listener: () => void): Promise<PluginListenerHandle>;
816
+ /**
817
+ * Periodic tick with the latest known location. Receives a {@link Location}
818
+ * once the native service has at least one fix. Early ticks (before any GPS
819
+ * fix) deliver an empty object — guard with `if ('latitude' in event)`.
820
+ *
821
+ * @since 1.0.0
822
+ */
823
+ addListener(eventName: 'heartbeat', listener: (event: Location) => void): Promise<PluginListenerHandle>;
824
+ /**
825
+ * A batch upload to `syncUrl` started.
826
+ *
827
+ * @since 1.0.0
828
+ */
829
+ addListener(eventName: 'syncStart', listener: () => void): Promise<PluginListenerHandle>;
830
+ /**
831
+ * Sync upload progress (0..100).
832
+ *
833
+ * @since 1.0.0
834
+ */
835
+ addListener(eventName: 'syncProgress', listener: (event: {
836
+ progress: number;
837
+ }) => void): Promise<PluginListenerHandle>;
838
+ /**
839
+ * Sync upload completed successfully.
840
+ *
841
+ * @since 1.0.0
842
+ */
843
+ addListener(eventName: 'syncSuccess', listener: (event: {
844
+ sent: number;
845
+ }) => void): Promise<PluginListenerHandle>;
846
+ /**
847
+ * Sync upload failed.
848
+ *
849
+ * @since 1.0.0
850
+ */
851
+ addListener(eventName: 'syncError', listener: (event: {
852
+ httpStatus: number;
853
+ message: string;
854
+ }) => void): Promise<PluginListenerHandle>;
855
+ /**
856
+ * A trip started (driver insights).
857
+ *
858
+ * @since 1.0.0
859
+ */
860
+ addListener(eventName: 'tripStart', listener: (event: Location) => void): Promise<PluginListenerHandle>;
861
+ /**
862
+ * A trip ended (driver insights).
863
+ *
864
+ * @since 1.0.0
865
+ */
866
+ addListener(eventName: 'tripEnd', listener: (event: {
867
+ location: Location;
868
+ distance: number;
869
+ durationMs: number;
870
+ }) => void): Promise<PluginListenerHandle>;
871
+ /**
872
+ * User started moving (driver insights).
873
+ *
874
+ * @since 1.0.0
875
+ */
876
+ addListener(eventName: 'moving', listener: (event: Location) => void): Promise<PluginListenerHandle>;
877
+ /**
878
+ * User stopped (driver insights).
879
+ *
880
+ * @since 1.0.0
881
+ */
882
+ addListener(eventName: 'stopped', listener: (event: Location) => void): Promise<PluginListenerHandle>;
883
+ /**
884
+ * Speed crossed above `drivingEvents.speedLimit`.
885
+ *
886
+ * @since 1.0.0
887
+ */
888
+ addListener(eventName: 'speeding', listener: (event: {
889
+ location: Location;
890
+ speedKmh: number;
891
+ limitKmh: number;
892
+ }) => void): Promise<PluginListenerHandle>;
893
+ /**
894
+ * Native location provider changed (gps ↔ network ↔ fused).
895
+ *
896
+ * @since 1.0.0
897
+ */
898
+ addListener(eventName: 'providerChange', listener: (event: {
899
+ provider: string;
900
+ }) => void): Promise<PluginListenerHandle>;
901
+ /**
902
+ * `triggerSOS()` was invoked.
903
+ *
904
+ * @since 1.0.0
905
+ */
906
+ addListener(eventName: 'sos', listener: (event: {
907
+ location?: Location;
908
+ [key: string]: unknown;
909
+ }) => void): Promise<PluginListenerHandle>;
910
+ /**
911
+ * GPS-derived hard brake.
912
+ *
913
+ * @since 1.0.0
914
+ */
915
+ addListener(eventName: 'hardBrake', listener: (event: {
916
+ location: Location;
917
+ value: number;
918
+ }) => void): Promise<PluginListenerHandle>;
919
+ /**
920
+ * GPS-derived rapid acceleration.
921
+ *
922
+ * @since 1.0.0
923
+ */
924
+ addListener(eventName: 'rapidAcceleration', listener: (event: {
925
+ location: Location;
926
+ value: number;
927
+ }) => void): Promise<PluginListenerHandle>;
928
+ /**
929
+ * GPS-derived sharp turn.
930
+ *
931
+ * @since 1.0.0
932
+ */
933
+ addListener(eventName: 'sharpTurn', listener: (event: {
934
+ location: Location;
935
+ value: number;
936
+ }) => void): Promise<PluginListenerHandle>;
937
+ /**
938
+ * Heuristic possible-crash detection (GPS or sensor pipeline).
939
+ *
940
+ * @since 1.0.0
941
+ */
942
+ addListener(eventName: 'possibleCrash', listener: (event: {
943
+ location: Location;
944
+ value: number;
945
+ source: 'gps' | 'sensor';
946
+ }) => void): Promise<PluginListenerHandle>;
947
+ /**
948
+ * Sustained phone interaction during an active trip.
949
+ *
950
+ * @since 1.0.0
951
+ */
952
+ addListener(eventName: 'phoneUsageWhileDriving', listener: (event: {
953
+ location?: Location;
954
+ }) => void): Promise<PluginListenerHandle>;
955
+ }
956
+ /** Event name strings (compatibility with `@awesome-cordova-plugins` style). @since 1.0.0 */
957
+ export declare enum BackgroundGeolocationEvents {
958
+ http_authorization = "http_authorization",
959
+ abort_requested = "abort_requested",
960
+ background = "background",
961
+ foreground = "foreground",
962
+ authorization = "authorization",
963
+ error = "error",
964
+ stop = "stop",
965
+ start = "start",
966
+ activity = "activity",
967
+ stationary = "stationary",
968
+ location = "location",
969
+ heartbeat = "heartbeat",
970
+ syncStart = "syncStart",
971
+ syncProgress = "syncProgress",
972
+ syncSuccess = "syncSuccess",
973
+ syncError = "syncError",
974
+ tripStart = "tripStart",
975
+ tripEnd = "tripEnd",
976
+ moving = "moving",
977
+ stopped = "stopped",
978
+ speeding = "speeding",
979
+ providerChange = "providerChange",
980
+ sos = "sos",
981
+ hardBrake = "hardBrake",
982
+ rapidAcceleration = "rapidAcceleration",
983
+ sharpTurn = "sharpTurn",
984
+ possibleCrash = "possibleCrash",
985
+ phoneUsageWhileDriving = "phoneUsageWhileDriving"
986
+ }
987
+ /** Location error codes. @since 1.0.0 */
988
+ export declare enum BackgroundGeolocationLocationCode {
989
+ PERMISSION_DENIED = 1,
990
+ LOCATION_UNAVAILABLE = 2,
991
+ TIMEOUT = 3
992
+ }
993
+ /** Native provider strings. @since 1.0.0 */
994
+ export declare enum BackgroundGeolocationNativeProvider {
995
+ gps = "gps",
996
+ network = "network",
997
+ passive = "passive",
998
+ fused = "fused"
999
+ }
1000
+ /** Location provider IDs. @since 1.0.0 */
1001
+ export declare enum BackgroundGeolocationLocationProvider {
1002
+ DISTANCE_FILTER_PROVIDER = 0,
1003
+ ACTIVITY_PROVIDER = 1,
1004
+ RAW_PROVIDER = 2
1005
+ }
1006
+ /** Authorization status. @since 1.0.0 */
1007
+ export declare enum BackgroundGeolocationAuthorizationStatus {
1008
+ NOT_AUTHORIZED = 0,
1009
+ AUTHORIZED = 1,
1010
+ AUTHORIZED_FOREGROUND = 2
1011
+ }
1012
+ /** Log levels. @since 1.0.0 */
1013
+ export declare enum BackgroundGeolocationLogLevel {
1014
+ TRACE = "TRACE",
1015
+ DEBUG = "DEBUG",
1016
+ INFO = "INFO",
1017
+ WARN = "WARN",
1018
+ ERROR = "ERROR"
1019
+ }
1020
+ /** Provider enum (compatibility with `@awesome-cordova-plugins` style). @since 1.0.0 */
1021
+ export declare enum BackgroundGeolocationProvider {
1022
+ ANDROID_DISTANCE_FILTER_PROVIDER = 0,
1023
+ ANDROID_ACTIVITY_PROVIDER = 1,
1024
+ RAW_PROVIDER = 2
1025
+ }
1026
+ /** Desired accuracy in meters. @since 1.0.0 */
1027
+ export declare enum BackgroundGeolocationAccuracy {
1028
+ HIGH = 0,
1029
+ MEDIUM = 100,
1030
+ LOW = 1000,
1031
+ PASSIVE = 10000
1032
+ }
1033
+ /** Mode for `switchMode`. @since 1.0.0 */
1034
+ export declare enum BackgroundGeolocationMode {
1035
+ BACKGROUND = 0,
1036
+ FOREGROUND = 1
1037
+ }
1038
+ /** iOS activity type. @since 1.0.0 */
1039
+ export declare enum BackgroundGeolocationIOSActivity {
1040
+ AutomotiveNavigation = "AutomotiveNavigation",
1041
+ OtherNavigation = "OtherNavigation",
1042
+ Fitness = "Fitness",
1043
+ Other = "Other"
1044
+ }
1045
+ /** Alias for {@link ConfigureOptions}. @since 1.0.0 */
1046
+ export type BackgroundGeolocationConfig = ConfigureOptions;
1047
+ /** Alias for {@link Location}. @since 1.0.0 */
1048
+ export type BackgroundGeolocationResponse = Location;
1049
+ /** Alias for {@link CurrentLocationOptions}. @since 1.0.0 */
1050
+ export type BackgroundGeolocationCurrentPositionConfig = CurrentLocationOptions;
1051
+ /** Alias for {@link LogEntry}. @since 1.0.0 */
1052
+ export type BackgroundGeolocationLogEntry = LogEntry;