@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.
- package/JosuelmmCapacitorBackgroundGeolocation.podspec +34 -0
- package/LICENSE +17 -0
- package/NOTICE.md +32 -0
- package/Package.swift +45 -0
- package/README.md +402 -0
- package/android/build.gradle +79 -0
- package/android/proguard-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +83 -0
- package/android/src/main/java/com/evgenii/jsevaluator/HandlerWrapper.java +18 -0
- package/android/src/main/java/com/evgenii/jsevaluator/JavaScriptInterface.java +22 -0
- package/android/src/main/java/com/evgenii/jsevaluator/JsEvaluator.java +133 -0
- package/android/src/main/java/com/evgenii/jsevaluator/JsFunctionCallFormatter.java +37 -0
- package/android/src/main/java/com/evgenii/jsevaluator/WebViewWrapper.java +71 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/CallJavaResultInterface.java +8 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/HandlerWrapperInterface.java +5 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/JsCallback.java +10 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/JsEvaluatorInterface.java +18 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/WebViewWrapperInterface.java +14 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/BackgroundGeolocationPlugin.java +898 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/ConfigMapper.java +303 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/HeadlessTaskRegistry.java +34 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/JsEvaluatorTaskRunner.java +63 -0
- package/android/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +699 -0
- package/android/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +103 -0
- package/android/src/main/java/com/marianhello/bgloc/Config.java +1155 -0
- package/android/src/main/java/com/marianhello/bgloc/ConnectivityListener.java +5 -0
- package/android/src/main/java/com/marianhello/bgloc/HttpPostService.java +362 -0
- package/android/src/main/java/com/marianhello/bgloc/LocationManager.java +138 -0
- package/android/src/main/java/com/marianhello/bgloc/PluginDelegate.java +45 -0
- package/android/src/main/java/com/marianhello/bgloc/PluginException.java +38 -0
- package/android/src/main/java/com/marianhello/bgloc/PostLocationTask.java +238 -0
- package/android/src/main/java/com/marianhello/bgloc/ResourceResolver.java +55 -0
- package/android/src/main/java/com/marianhello/bgloc/data/AbstractLocationTemplate.java +69 -0
- package/android/src/main/java/com/marianhello/bgloc/data/ArrayListLocationTemplate.java +88 -0
- package/android/src/main/java/com/marianhello/bgloc/data/BackgroundActivity.java +108 -0
- package/android/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +1088 -0
- package/android/src/main/java/com/marianhello/bgloc/data/ConfigJsonMapper.java +211 -0
- package/android/src/main/java/com/marianhello/bgloc/data/ConfigurationDAO.java +13 -0
- package/android/src/main/java/com/marianhello/bgloc/data/DAOFactory.java +17 -0
- package/android/src/main/java/com/marianhello/bgloc/data/HashMapLocationTemplate.java +82 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +27 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplate.java +12 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +71 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationTransform.java +19 -0
- package/android/src/main/java/com/marianhello/bgloc/data/SessionLocationDAO.java +18 -0
- package/android/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +406 -0
- package/android/src/main/java/com/marianhello/bgloc/data/provider/LocationContentProvider.java +321 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +94 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +227 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +122 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +550 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +189 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteSessionContract.java +74 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteSessionLocationDAO.java +169 -0
- package/android/src/main/java/com/marianhello/bgloc/driving/DrivingEventsDetector.java +265 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/AbstractTaskRunner.java +15 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/ActivityTask.java +48 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/JsCallback.java +10 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/LocationTask.java +60 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/StationaryTask.java +25 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/Task.java +8 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunner.java +5 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunnerFactory.java +8 -0
- package/android/src/main/java/com/marianhello/bgloc/http/UrlTemplateResolver.java +115 -0
- package/android/src/main/java/com/marianhello/bgloc/oem/BatteryOemHelper.java +214 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +218 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +385 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +685 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/LocationProvider.java +32 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/LocationProviderFactory.java +47 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/ProviderDelegate.java +12 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +175 -0
- package/android/src/main/java/com/marianhello/bgloc/sensor/SensorFusionDetector.java +199 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationService.java +16 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +1531 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfo.java +6 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfoImpl.java +41 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java +203 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +156 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/AccountHelper.java +39 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/Authenticator.java +68 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/AuthenticatorService.java +28 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +311 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java +148 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +301 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/SyncService.java +68 -0
- package/android/src/main/java/com/marianhello/logging/DBLogReader.java +208 -0
- package/android/src/main/java/com/marianhello/logging/LogEntry.java +99 -0
- package/android/src/main/java/com/marianhello/logging/LoggerManager.java +70 -0
- package/android/src/main/java/com/marianhello/logging/UncaughtExceptionLogger.java +36 -0
- package/android/src/main/java/com/marianhello/utils/CloneHelper.java +22 -0
- package/android/src/main/java/com/marianhello/utils/Convert.java +56 -0
- package/android/src/main/java/com/marianhello/utils/TextUtils.java +72 -0
- package/android/src/main/java/com/marianhello/utils/ToneGenerator.java +68 -0
- package/android/src/main/java/org/apache/commons/io/Charsets.java +153 -0
- package/android/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +344 -0
- package/android/src/main/java/org/chromium/content/browser/ThreadUtils.java +134 -0
- package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlExpression.java +398 -0
- package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlSelectStatement.java +671 -0
- package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlStatement.java +29 -0
- package/android/src/main/java/ru/andremoniy/utils/TextUtils.java +61 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/values/strings.xml +15 -0
- package/android/src/main/res/xml/authenticator.xml +7 -0
- package/android/src/main/res/xml/syncadapter.xml +9 -0
- package/dist/esm/definitions.d.ts +1052 -0
- package/dist/esm/definitions.js +142 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +92 -0
- package/dist/esm/web.js +242 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +415 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +418 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin-Bridging-Header.h +18 -0
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.m +52 -0
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.swift +750 -0
- package/ios/Tests/BackgroundGeolocationPluginTests/BackgroundGeolocationPluginTests.swift +12 -0
- package/ios/common/BackgroundGeolocation/CocoaLumberjack.h +1945 -0
- package/ios/common/BackgroundGeolocation/CocoaLumberjack.m +5255 -0
- package/ios/common/BackgroundGeolocation/FMDB.h +2357 -0
- package/ios/common/BackgroundGeolocation/FMDB.m +2672 -0
- package/ios/common/BackgroundGeolocation/FMDBLogger.h +42 -0
- package/ios/common/BackgroundGeolocation/FMDBLogger.m +264 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.h +41 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.m +68 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager+Internal.h +33 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.h +178 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.m +1025 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.h +103 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.m +238 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequestDefines.h +163 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.h +39 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.m +37 -0
- package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.h +51 -0
- package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.m +53 -0
- package/ios/common/BackgroundGeolocation/MAURActivity.h +23 -0
- package/ios/common/BackgroundGeolocation/MAURActivity.m +52 -0
- package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.h +18 -0
- package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +340 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +88 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +1193 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +46 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +283 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.h +25 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.m +105 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.h +99 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.m +636 -0
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +53 -0
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +54 -0
- package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.h +20 -0
- package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +550 -0
- package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.h +17 -0
- package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +124 -0
- package/ios/common/BackgroundGeolocation/MAURLocation.h +73 -0
- package/ios/common/BackgroundGeolocation/MAURLocation.m +392 -0
- package/ios/common/BackgroundGeolocation/MAURLocationContract.h +38 -0
- package/ios/common/BackgroundGeolocation/MAURLocationContract.m +39 -0
- package/ios/common/BackgroundGeolocation/MAURLocationManager.h +53 -0
- package/ios/common/BackgroundGeolocation/MAURLocationManager.m +305 -0
- package/ios/common/BackgroundGeolocation/MAURLogReader.h +26 -0
- package/ios/common/BackgroundGeolocation/MAURLogReader.m +122 -0
- package/ios/common/BackgroundGeolocation/MAURLogging.h +19 -0
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +53 -0
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +367 -0
- package/ios/common/BackgroundGeolocation/MAURProviderDelegate.h +52 -0
- package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.h +18 -0
- package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +138 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.h +26 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +335 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.h +57 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.m +93 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +52 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +520 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.h +32 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.m +276 -0
- package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.h +41 -0
- package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.m +137 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationContract.h +29 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationContract.m +31 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationDAO.h +25 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationDAO.m +153 -0
- package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.h +20 -0
- package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.m +62 -0
- package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.h +31 -0
- package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.m +107 -0
- package/ios/common/BackgroundGeolocation/Reachability.h +102 -0
- package/ios/common/BackgroundGeolocation/Reachability.m +475 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/README.md +170 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.h +55 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.m +47 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlDataManipulationCommand.h +27 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.h +250 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.m +259 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.h +360 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.m +427 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlStatement.h +37 -0
- package/ios/common/BackgroundGeolocation/module.modulemap +16 -0
- package/package.json +82 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
repo_url = package['repository']['url']
|
|
5
|
+
# `pod spec lint` rejects `git+` URLs and `.git` suffixes for `homepage`,
|
|
6
|
+
# but tolerates them in `source[:git]`. Normalize once here.
|
|
7
|
+
homepage_url = repo_url.sub(/^git\+/, '').sub(/\.git$/, '')
|
|
8
|
+
source_git = repo_url.sub(/^git\+/, '')
|
|
9
|
+
|
|
10
|
+
Pod::Spec.new do |s|
|
|
11
|
+
s.name = 'JosuelmmCapacitorBackgroundGeolocation'
|
|
12
|
+
s.version = package['version']
|
|
13
|
+
s.summary = package['description']
|
|
14
|
+
s.license = package['license']
|
|
15
|
+
s.homepage = homepage_url
|
|
16
|
+
s.author = package['author']
|
|
17
|
+
s.source = { :git => source_git, :tag => s.version.to_s }
|
|
18
|
+
s.source_files = [
|
|
19
|
+
'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}',
|
|
20
|
+
'ios/common/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
21
|
+
]
|
|
22
|
+
s.public_header_files = 'ios/common/BackgroundGeolocation/MAUR*.h'
|
|
23
|
+
s.module_map = 'ios/common/BackgroundGeolocation/module.modulemap'
|
|
24
|
+
s.ios.deployment_target = '14.0'
|
|
25
|
+
s.dependency 'Capacitor'
|
|
26
|
+
s.swift_version = '5.9'
|
|
27
|
+
s.frameworks = 'CoreLocation', 'CoreMotion', 'UIKit'
|
|
28
|
+
s.libraries = 'sqlite3'
|
|
29
|
+
s.requires_arc = true
|
|
30
|
+
s.pod_target_xcconfig = {
|
|
31
|
+
'SWIFT_OBJC_BRIDGING_HEADER' => '$(PODS_TARGET_SRCROOT)/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin-Bridging-Header.h',
|
|
32
|
+
'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/ios/common/BackgroundGeolocation $(PODS_TARGET_SRCROOT)/ios/common/BackgroundGeolocation/INTULocationManager $(PODS_TARGET_SRCROOT)/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext $(PODS_TARGET_SRCROOT)/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql'
|
|
33
|
+
}
|
|
34
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2026 JosueLMM
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
14
|
+
|
|
15
|
+
SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
Full license text: https://www.apache.org/licenses/LICENSE-2.0.txt
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# NOTICE
|
|
2
|
+
|
|
3
|
+
`@josuelmm/capacitor-background-geolocation`
|
|
4
|
+
|
|
5
|
+
This Capacitor plugin is derived from prior work. Credits below.
|
|
6
|
+
|
|
7
|
+
## Native core
|
|
8
|
+
|
|
9
|
+
The Android core under `com.marianhello.bgloc` and the iOS core under the
|
|
10
|
+
`MAUR*` prefix are copied (with minor adaptation) from:
|
|
11
|
+
|
|
12
|
+
- `@josuelmm/cordova-background-geolocation`
|
|
13
|
+
https://github.com/josuelmm/cordova-background-geolocation
|
|
14
|
+
- Original upstream: `mauron85/cordova-plugin-background-geolocation`
|
|
15
|
+
https://github.com/mauron85/cordova-plugin-background-geolocation
|
|
16
|
+
|
|
17
|
+
Original native core is distributed under Apache License 2.0.
|
|
18
|
+
|
|
19
|
+
## Capacitor bridge
|
|
20
|
+
|
|
21
|
+
The Capacitor bridge classes, TypeScript API, build configuration,
|
|
22
|
+
podspec, `Package.swift` and example app are original work by
|
|
23
|
+
JosueLMM and distributed under Apache License 2.0.
|
|
24
|
+
|
|
25
|
+
## Structural inspiration
|
|
26
|
+
|
|
27
|
+
The repository layout, build scripts and example app structure take
|
|
28
|
+
non-substantial inspiration from the Cap-go Capacitor plugin scaffold,
|
|
29
|
+
which is published under MPL-2.0. No source files are copied from it;
|
|
30
|
+
only directory shape and tooling conventions.
|
|
31
|
+
|
|
32
|
+
- https://github.com/Cap-go/capacitor-background-geolocation
|
package/Package.swift
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// swift-tools-version: 5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "JosuelmmCapacitorBackgroundGeolocation",
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(
|
|
9
|
+
name: "JosuelmmCapacitorBackgroundGeolocation",
|
|
10
|
+
targets: ["BackgroundGeolocationPlugin"])
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(
|
|
17
|
+
name: "MAURBackgroundGeolocation",
|
|
18
|
+
path: "ios/common/BackgroundGeolocation",
|
|
19
|
+
publicHeadersPath: ".",
|
|
20
|
+
cSettings: [
|
|
21
|
+
.headerSearchPath("."),
|
|
22
|
+
.headerSearchPath("INTULocationManager"),
|
|
23
|
+
.headerSearchPath("SQLQueryBuilder/ext"),
|
|
24
|
+
.headerSearchPath("SQLQueryBuilder/sql")
|
|
25
|
+
],
|
|
26
|
+
linkerSettings: [
|
|
27
|
+
.linkedLibrary("sqlite3"),
|
|
28
|
+
.linkedFramework("CoreLocation"),
|
|
29
|
+
.linkedFramework("CoreMotion"),
|
|
30
|
+
.linkedFramework("UIKit")
|
|
31
|
+
]
|
|
32
|
+
),
|
|
33
|
+
.target(
|
|
34
|
+
name: "BackgroundGeolocationPlugin",
|
|
35
|
+
dependencies: [
|
|
36
|
+
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
37
|
+
"MAURBackgroundGeolocation"
|
|
38
|
+
],
|
|
39
|
+
path: "ios/Sources/BackgroundGeolocationPlugin"),
|
|
40
|
+
.testTarget(
|
|
41
|
+
name: "BackgroundGeolocationPluginTests",
|
|
42
|
+
dependencies: ["BackgroundGeolocationPlugin"],
|
|
43
|
+
path: "ios/Tests/BackgroundGeolocationPluginTests")
|
|
44
|
+
]
|
|
45
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- Copyright (c) 2026 JosueLMM -->
|
|
3
|
+
|
|
4
|
+
# @josuelmm/capacitor-background-geolocation
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/@josuelmm/capacitor-background-geolocation)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://capacitorjs.com/)
|
|
9
|
+
|
|
10
|
+
Capacitor 8+ plugin for accurate background geolocation tracking on iOS and
|
|
11
|
+
Android. Derived from the `@josuelmm/cordova-background-geolocation` native
|
|
12
|
+
core (a fork of [`mauron85/cordova-plugin-background-geolocation`](https://github.com/mauron85/cordova-plugin-background-geolocation)),
|
|
13
|
+
ported to the Capacitor bridge with a Promise-based API and `addListener`
|
|
14
|
+
events.
|
|
15
|
+
|
|
16
|
+
v1.0.0 brings full TypeScript-API parity with the Cordova source plugin:
|
|
17
|
+
**40 methods + 28 events**, the full `ConfigureOptions` surface, extended
|
|
18
|
+
`Diagnostics`, OEM helpers, sync/session queue management, driver-insight
|
|
19
|
+
events, and `@awesome-cordova-plugins`-style compatibility enums.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @josuelmm/capacitor-background-geolocation
|
|
25
|
+
npx cap sync
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Requires `@capacitor/core` >= 8.0.0.
|
|
29
|
+
|
|
30
|
+
## iOS setup
|
|
31
|
+
|
|
32
|
+
Add to `ios/App/App/Info.plist`:
|
|
33
|
+
|
|
34
|
+
```xml
|
|
35
|
+
<key>NSLocationWhenInUseUsageDescription</key>
|
|
36
|
+
<string>This app needs your location to track activity.</string>
|
|
37
|
+
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
|
38
|
+
<string>This app needs your location even when the app is in the background.</string>
|
|
39
|
+
<key>NSMotionUsageDescription</key>
|
|
40
|
+
<string>This app uses motion data to detect when you are moving.</string>
|
|
41
|
+
<key>UIBackgroundModes</key>
|
|
42
|
+
<array>
|
|
43
|
+
<string>location</string>
|
|
44
|
+
<string>fetch</string>
|
|
45
|
+
</array>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Android setup
|
|
49
|
+
|
|
50
|
+
Add to `android/app/src/main/AndroidManifest.xml` (inside `<manifest>`):
|
|
51
|
+
|
|
52
|
+
```xml
|
|
53
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
54
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
55
|
+
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
|
56
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
57
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
|
58
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
|
59
|
+
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
|
|
60
|
+
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
61
|
+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
|
62
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Runtime permission flow (API 23+) — request foreground first, then background:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { BackgroundGeolocation } from '@josuelmm/capacitor-background-geolocation';
|
|
69
|
+
|
|
70
|
+
const { location } = await BackgroundGeolocation.requestPermissions();
|
|
71
|
+
if (location !== 'granted') {
|
|
72
|
+
await BackgroundGeolocation.showAppSettings();
|
|
73
|
+
}
|
|
74
|
+
// Android 10+: separate background-location prompt
|
|
75
|
+
await BackgroundGeolocation.requestBackgroundLocationPermission();
|
|
76
|
+
// Android 13+: notification permission for the foreground-service icon
|
|
77
|
+
await BackgroundGeolocation.requestNotificationPermission();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`FOREGROUND_SERVICE_LOCATION` is mandatory on Android 14 (API 34+); the plugin
|
|
81
|
+
declares its foreground service with `foregroundServiceType="location"`.
|
|
82
|
+
|
|
83
|
+
## Web limitations
|
|
84
|
+
|
|
85
|
+
The web fallback uses `navigator.geolocation` and only works while the page is
|
|
86
|
+
alive. Sync queue, sessions, OEM screens, and other native-only methods throw
|
|
87
|
+
`unimplemented`. `getDiagnostics`, `getPluginVersion`, and `triggerSOS` resolve
|
|
88
|
+
with neutral payloads so app code stays portable.
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { BackgroundGeolocation } from '@josuelmm/capacitor-background-geolocation';
|
|
94
|
+
|
|
95
|
+
await BackgroundGeolocation.configure({
|
|
96
|
+
locationProvider: 'DISTANCE_FILTER',
|
|
97
|
+
desiredAccuracy: 'HIGH',
|
|
98
|
+
stationaryRadius: 25,
|
|
99
|
+
distanceFilter: 10,
|
|
100
|
+
stopOnTerminate: false,
|
|
101
|
+
startOnBoot: false,
|
|
102
|
+
startForeground: true,
|
|
103
|
+
notificationTitle: 'Tracking',
|
|
104
|
+
notificationText: 'Location enabled',
|
|
105
|
+
url: 'https://example.com/locations',
|
|
106
|
+
syncUrl: 'https://example.com/sync',
|
|
107
|
+
heartbeatInterval: 30_000,
|
|
108
|
+
drivingEvents: { enabled: true, speedLimit: 90 },
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const sub = await BackgroundGeolocation.addListener('location', (loc) => {
|
|
112
|
+
console.log('fix', loc.latitude, loc.longitude);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await BackgroundGeolocation.start();
|
|
116
|
+
// ...
|
|
117
|
+
await BackgroundGeolocation.stop();
|
|
118
|
+
sub.remove();
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## API reference
|
|
122
|
+
|
|
123
|
+
### Tracking control
|
|
124
|
+
|
|
125
|
+
| Method | Description |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `configure(options)` | Set the native plugin options. Required before `start`. |
|
|
128
|
+
| `start()` | Start the background service. |
|
|
129
|
+
| `stop()` | Stop the background service. |
|
|
130
|
+
| `switchMode({ mode })` | iOS: switch BACKGROUND (`0`) / FOREGROUND (`1`) mode. |
|
|
131
|
+
| `checkStatus()` | Service status snapshot (`isRunning`, `locationServicesEnabled`, `authorization`). |
|
|
132
|
+
|
|
133
|
+
### Locations
|
|
134
|
+
|
|
135
|
+
| Method | Description |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `getCurrentLocation(opts?)` | One-shot location fix. |
|
|
138
|
+
| `getStationaryLocation()` | Last stationary fix, or `null`. |
|
|
139
|
+
| `getLocations()` | All locations stored locally. |
|
|
140
|
+
| `getValidLocations()` | Locations not yet POSTed to `url`. |
|
|
141
|
+
| `getValidLocationsAndDelete()` | Same as above, but deletes the rows returned. |
|
|
142
|
+
| `deleteLocation({ locationId })` | Delete a single stored location. |
|
|
143
|
+
| `deleteAllLocations()` | Wipe every stored location. |
|
|
144
|
+
|
|
145
|
+
### Sync queue
|
|
146
|
+
|
|
147
|
+
| Method | Description |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| `forceSync()` | Force-flush the sync queue to `syncUrl`. |
|
|
150
|
+
| `clearSync()` | Discard every pending sync-queue entry. |
|
|
151
|
+
| `getPendingSyncCount()` | Count of locations waiting to be synced. |
|
|
152
|
+
|
|
153
|
+
### Sessions
|
|
154
|
+
|
|
155
|
+
| Method | Description |
|
|
156
|
+
| --- | --- |
|
|
157
|
+
| `startSession()` | Begin a recording session (clears the session table). |
|
|
158
|
+
| `getSessionLocations()` | All locations in the current session. |
|
|
159
|
+
| `clearSession()` | Clear the session table and stop collecting. |
|
|
160
|
+
| `getSessionLocationsCount()` | Count of locations in the current session. |
|
|
161
|
+
|
|
162
|
+
### Diagnostics & OEMs
|
|
163
|
+
|
|
164
|
+
| Method | Description |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| `getDiagnostics()` | Permissions, battery optimisation, OEM, iOS flags. |
|
|
167
|
+
| `isIgnoringBatteryOptimizations()` | Android battery-optimisation whitelist state. |
|
|
168
|
+
| `requestIgnoreBatteryOptimizations()` | Prompt the user to whitelist the app. |
|
|
169
|
+
| `openBatterySettings()` | Open the battery settings screen (Android). |
|
|
170
|
+
| `openAutoStartSettings()` | Open the OEM auto-start/background-activity screen. |
|
|
171
|
+
| `getManufacturerHelp()` | OEM-specific user instructions. |
|
|
172
|
+
| `getPluginVersion()` | Native plugin version string. |
|
|
173
|
+
|
|
174
|
+
### Permissions
|
|
175
|
+
|
|
176
|
+
| Method | Description |
|
|
177
|
+
| --- | --- |
|
|
178
|
+
| `checkPermissions()` | Capacitor-style location permission state. |
|
|
179
|
+
| `requestPermissions()` | Prompt for foreground location. |
|
|
180
|
+
| `requestBackgroundLocationPermission()` | Android 10+ background location. |
|
|
181
|
+
| `requestActivityRecognitionPermission()` | Android 10+ activity recognition. |
|
|
182
|
+
| `requestNotificationPermission()` | Android 13+ notifications. |
|
|
183
|
+
| `showAppSettings()` | Open this app's settings page. |
|
|
184
|
+
| `openSettings()` | Alias for `showAppSettings`. |
|
|
185
|
+
| `showLocationSettings()` | Open the system Location settings (Android). |
|
|
186
|
+
|
|
187
|
+
### Tasks
|
|
188
|
+
|
|
189
|
+
| Method | Description |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| `startTask()` | iOS: begin a background task; returns `{ taskKey }`. |
|
|
192
|
+
| `endTask({ taskKey })` | iOS: end the background task. |
|
|
193
|
+
| `triggerSOS(payload?)` | Emit an `sos` event with the latest known location. |
|
|
194
|
+
| `headlessTask(fn)` | Android: register a JS callback that runs even when the activity has been killed. iOS no-op. |
|
|
195
|
+
|
|
196
|
+
### Config & logs
|
|
197
|
+
|
|
198
|
+
| Method | Description |
|
|
199
|
+
| --- | --- |
|
|
200
|
+
| `getConfig()` | Returns the persisted configuration. |
|
|
201
|
+
| `getLogEntries({ limit, fromId?, minLevel? })` | Tail the native plugin log. |
|
|
202
|
+
|
|
203
|
+
### Lifecycle
|
|
204
|
+
|
|
205
|
+
| Method | Description |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| `removeAllListeners()` | Detach every active listener. |
|
|
208
|
+
|
|
209
|
+
## Events
|
|
210
|
+
|
|
211
|
+
Subscribe with `addListener(eventName, handler)`. The handle's `remove()`
|
|
212
|
+
detaches a single listener.
|
|
213
|
+
|
|
214
|
+
| Event | Payload | Description |
|
|
215
|
+
| --- | --- | --- |
|
|
216
|
+
| `location` | `Location` | New fix. |
|
|
217
|
+
| `stationary` | `StationaryLocation` | Stationary state entered. |
|
|
218
|
+
| `activity` | `Activity` | Activity recognition update. |
|
|
219
|
+
| `start` | `void` | Service started. |
|
|
220
|
+
| `stop` | `void` | Service stopped. |
|
|
221
|
+
| `error` | `BackgroundGeolocationError` | Recoverable or fatal error. |
|
|
222
|
+
| `authorization` | `{ status }` | Authorization state changed. |
|
|
223
|
+
| `foreground` | `void` | App entered the foreground. |
|
|
224
|
+
| `background` | `void` | App entered the background. |
|
|
225
|
+
| `abort_requested` | `void` | Server returned `285 Updates Not Required`. |
|
|
226
|
+
| `http_authorization` | `void` | Server returned `401 Unauthorized`. |
|
|
227
|
+
| `heartbeat` | `{ location? }` | Periodic tick with latest known location. |
|
|
228
|
+
| `syncStart` | `void` | Batch sync upload started. |
|
|
229
|
+
| `syncProgress` | `{ progress }` | Sync upload progress (0..100). |
|
|
230
|
+
| `syncSuccess` | `{ sent }` | Sync upload completed. |
|
|
231
|
+
| `syncError` | `{ httpStatus, message }` | Sync upload failed. |
|
|
232
|
+
| `tripStart` | `Location` | Trip started (driver insights). |
|
|
233
|
+
| `tripEnd` | `{ location, distance, durationMs }` | Trip ended. |
|
|
234
|
+
| `moving` | `Location` | User started moving. |
|
|
235
|
+
| `stopped` | `Location` | User stopped. |
|
|
236
|
+
| `speeding` | `{ location, speedKmh, limitKmh }` | Speed exceeded `drivingEvents.speedLimit`. |
|
|
237
|
+
| `providerChange` | `{ provider }` | Native location provider changed. |
|
|
238
|
+
| `sos` | `{ location?, ... }` | `triggerSOS()` was invoked. |
|
|
239
|
+
| `hardBrake` | `{ location, value }` | GPS-derived hard brake. |
|
|
240
|
+
| `rapidAcceleration` | `{ location, value }` | GPS-derived rapid acceleration. |
|
|
241
|
+
| `sharpTurn` | `{ location, value }` | GPS-derived sharp turn. |
|
|
242
|
+
| `possibleCrash` | `{ location, value, source }` | Heuristic crash detection. |
|
|
243
|
+
| `phoneUsageWhileDriving` | `{ location? }` | Sustained phone interaction during a trip. |
|
|
244
|
+
|
|
245
|
+
## Headless task (Android)
|
|
246
|
+
|
|
247
|
+
When `stopOnTerminate: false` and the user swipes the app away, Android
|
|
248
|
+
keeps the foreground service alive but kills the host activity. In that
|
|
249
|
+
state your regular `addListener` callbacks won't fire — the JS bridge no
|
|
250
|
+
longer exists.
|
|
251
|
+
|
|
252
|
+
`headlessTask` registers a small JS function that the plugin runs inside
|
|
253
|
+
a hidden Android WebView every time a `location`, `stationary`, or
|
|
254
|
+
`activity` event fires while the activity is gone.
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import { BackgroundGeolocation } from '@josuelmm/capacitor-background-geolocation';
|
|
258
|
+
|
|
259
|
+
await BackgroundGeolocation.configure({
|
|
260
|
+
stopOnTerminate: false,
|
|
261
|
+
startOnBoot: true,
|
|
262
|
+
// ...other options
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
await BackgroundGeolocation.headlessTask(function (event) {
|
|
266
|
+
// event.name : 'location' | 'stationary' | 'activity'
|
|
267
|
+
// event.params : the corresponding payload
|
|
268
|
+
if (event.name === 'location' || event.name === 'stationary') {
|
|
269
|
+
const xhr = new XMLHttpRequest();
|
|
270
|
+
xhr.open('POST', 'https://example.com/headless');
|
|
271
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
272
|
+
xhr.send(JSON.stringify(event.params));
|
|
273
|
+
}
|
|
274
|
+
return 'processed: ' + event.name;
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
await BackgroundGeolocation.start();
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Caveats:
|
|
281
|
+
|
|
282
|
+
- **Android only.** On iOS the call resolves immediately — Apple does not
|
|
283
|
+
allow running JS in a killed-app scenario. Use the regular
|
|
284
|
+
`addListener('location', …)` flow on iOS.
|
|
285
|
+
- **Isolated scope.** The function body is serialised via `fn.toString()`
|
|
286
|
+
and re-evaluated inside a fresh WebView. Closures, imports, and outer
|
|
287
|
+
variables are NOT available. Only `XMLHttpRequest`, `fetch`, `JSON`,
|
|
288
|
+
and the language built-ins.
|
|
289
|
+
- **Prefer `url` / `syncUrl`.** Configuring an HTTP endpoint on the
|
|
290
|
+
native side is more reliable than headless JS — the native sync layer
|
|
291
|
+
handles retries, batching, and OS-level battery throttling.
|
|
292
|
+
|
|
293
|
+
## Driving events
|
|
294
|
+
|
|
295
|
+
Set `drivingEvents.enabled: true` in `configure()` to turn on the
|
|
296
|
+
GPS-derived driver-insight pipeline. The native core then emits:
|
|
297
|
+
|
|
298
|
+
- `tripStart`, `tripEnd`, `moving`, `stopped` — sustained-speed state machine.
|
|
299
|
+
- `speeding` — when speed crosses `drivingEvents.speedLimit` (km/h).
|
|
300
|
+
- `providerChange` — OS switched between GPS / network / fused.
|
|
301
|
+
- `hardBrake`, `rapidAcceleration`, `sharpTurn` — sensor-free heuristics
|
|
302
|
+
from speed / bearing deltas.
|
|
303
|
+
- `possibleCrash` — sudden velocity drop or accelerometer impact. The
|
|
304
|
+
payload carries `source: 'gps' | 'sensor'`. **Always confirm with the
|
|
305
|
+
user before notifying anyone** — false positives are possible.
|
|
306
|
+
- `phoneUsageWhileDriving` — only when `drivingEvents.sensorFusion: true`,
|
|
307
|
+
via accelerometer + gyroscope jitter.
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
await BackgroundGeolocation.configure({
|
|
311
|
+
// ...tracking options
|
|
312
|
+
drivingEvents: {
|
|
313
|
+
enabled: true,
|
|
314
|
+
speedLimit: 90, // km/h, 0 to disable
|
|
315
|
+
minTripSpeed: 3.0, // m/s
|
|
316
|
+
minTripDuration: 30000, // ms
|
|
317
|
+
sensorFusion: false, // true → accel/gyro pipeline
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
BackgroundGeolocation.addListener('tripStart', (loc) => console.log('trip', loc));
|
|
322
|
+
BackgroundGeolocation.addListener('tripEnd', (e) =>
|
|
323
|
+
console.log('trip end', e.distance, 'm in', e.durationMs, 'ms'),
|
|
324
|
+
);
|
|
325
|
+
BackgroundGeolocation.addListener('speeding', (e) =>
|
|
326
|
+
console.warn('over limit', e.speedKmh, 'vs', e.limitKmh),
|
|
327
|
+
);
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Configuration reference
|
|
331
|
+
|
|
332
|
+
`ConfigureOptions` covers 60+ fields. Highlights:
|
|
333
|
+
|
|
334
|
+
- **Provider & accuracy**: `locationProvider`, `desiredAccuracy`,
|
|
335
|
+
`distanceFilter`, `stationaryRadius`, `maxAcceptedAccuracy`,
|
|
336
|
+
`activityConfidenceThreshold`.
|
|
337
|
+
- **Cadence**: `interval`, `fastestInterval`, `activitiesInterval`,
|
|
338
|
+
`heartbeatInterval`, `stationaryTimeout`, `stationaryPollInterval`,
|
|
339
|
+
`stationaryPollFast`.
|
|
340
|
+
- **Service lifecycle**: `stopOnTerminate`, `startOnBoot`,
|
|
341
|
+
`enableWatchdog`, `wakeLockMode`.
|
|
342
|
+
- **Notifications (Android)**: `notificationsEnabled`, `startForeground`,
|
|
343
|
+
`notificationTitle`, `notificationText`, `notificationIconColor`,
|
|
344
|
+
`notificationIconSmall`, `notificationIconLarge`,
|
|
345
|
+
`notificationSyncTitle`, `notificationSyncText`, `showTime`,
|
|
346
|
+
`showDistance`.
|
|
347
|
+
- **iOS-only**: `activityType`, `pauseLocationUpdates`,
|
|
348
|
+
`saveBatteryOnBackground`, `showsBackgroundLocationIndicator`.
|
|
349
|
+
- **HTTP transport**: `url`, `syncUrl`, `syncThreshold`, `sync`,
|
|
350
|
+
`headers`, `httpMethod`, `syncHttpMethod`, `httpMode`, `syncMode`,
|
|
351
|
+
`postTemplate`, `bodyTemplate`, `queryParams`, `maxLocations`.
|
|
352
|
+
- **Data quality**: `mockLocationPolicy` (`'allow' | 'flag' | 'drop'`),
|
|
353
|
+
`includeBattery`.
|
|
354
|
+
- **Driver insights**: `drivingEvents.{enabled, speedLimit, minTripSpeed,
|
|
355
|
+
hardBrakeMps2, rapidAccelMps2, sharpTurnDegPerSec, crashImpactKmh,
|
|
356
|
+
sensorFusion, crashImpactG, phoneUsageWindowMs, …}`.
|
|
357
|
+
|
|
358
|
+
Inspect `src/definitions.ts` (or the generated `.d.ts` in `dist/esm/`)
|
|
359
|
+
for the full annotated list with default values and JSDoc.
|
|
360
|
+
|
|
361
|
+
## Compatibility
|
|
362
|
+
|
|
363
|
+
- Capacitor `>=8.0.0`
|
|
364
|
+
- iOS `>=14.0`
|
|
365
|
+
- Android API `>=23` (Android 6.0)
|
|
366
|
+
- Web: foreground only via `navigator.geolocation`
|
|
367
|
+
|
|
368
|
+
## Migration from `@josuelmm/cordova-background-geolocation`
|
|
369
|
+
|
|
370
|
+
The TypeScript surface is intentionally identical in shape, with two
|
|
371
|
+
mechanical adaptations:
|
|
372
|
+
|
|
373
|
+
- **Promises instead of callbacks.** Every method that used
|
|
374
|
+
`success?, fail?` callbacks now returns `Promise<T>`. The resolved value is
|
|
375
|
+
what the Cordova `success` callback received, wrapped in an envelope object
|
|
376
|
+
when the return is a primitive (`getPendingSyncCount` → `{ count }`,
|
|
377
|
+
`getPluginVersion` → `{ version }`, `getLocations` → `{ locations }`, …).
|
|
378
|
+
- **`addListener` instead of `on`.** `BackgroundGeolocation.on('location', cb)`
|
|
379
|
+
becomes
|
|
380
|
+
```ts
|
|
381
|
+
const sub = await BackgroundGeolocation.addListener('location', cb);
|
|
382
|
+
// ...
|
|
383
|
+
sub.remove();
|
|
384
|
+
```
|
|
385
|
+
`removeAllListeners()` still detaches everything.
|
|
386
|
+
|
|
387
|
+
Type names from the Cordova plugin (`ConfigureOptions`, `Location`,
|
|
388
|
+
`StationaryLocation`, `LocationError`, `Activity`, `ServiceStatus`,
|
|
389
|
+
`Diagnostics`, `LogEntry`) are exported from this package. The
|
|
390
|
+
`@awesome-cordova-plugins`-style enums (`BackgroundGeolocationEvents`,
|
|
391
|
+
`BackgroundGeolocationLocationProvider`, etc.) are also re-exported so most
|
|
392
|
+
codebases compile with only the import-path swap.
|
|
393
|
+
|
|
394
|
+
`headlessTask(fn)` is supported on Android with the same signature as the
|
|
395
|
+
Cordova plugin — see [Headless task (Android)](#headless-task-android).
|
|
396
|
+
On iOS the call resolves as a no-op (Apple does not allow JS execution
|
|
397
|
+
while the host process is killed).
|
|
398
|
+
|
|
399
|
+
## License
|
|
400
|
+
|
|
401
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE.md](NOTICE.md) for attribution
|
|
402
|
+
to upstream contributors.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
androidxLocalbroadcastmanagerVersion = project.hasProperty('androidxLocalbroadcastmanagerVersion') ? rootProject.ext.androidxLocalbroadcastmanagerVersion : '1.1.0'
|
|
7
|
+
androidxWorkRuntimeVersion = project.hasProperty('androidxWorkRuntimeVersion') ? rootProject.ext.androidxWorkRuntimeVersion : '2.9.1'
|
|
8
|
+
playServicesLocationVersion = project.hasProperty('playServicesLocationVersion') ? rootProject.ext.playServicesLocationVersion : '21.3.0'
|
|
9
|
+
// Pulled in by the copied native core (com.marianhello.bgloc.*).
|
|
10
|
+
gsonVersion = project.hasProperty('gsonVersion') ? rootProject.ext.gsonVersion : '2.11.0'
|
|
11
|
+
slf4jVersion = project.hasProperty('slf4jVersion') ? rootProject.ext.slf4jVersion : '1.7.36'
|
|
12
|
+
logbackAndroidVersion = project.hasProperty('logbackAndroidVersion') ? rootProject.ext.logbackAndroidVersion : '3.0.0'
|
|
13
|
+
androidPermissionsVersion = project.hasProperty('androidPermissionsVersion') ? rootProject.ext.androidPermissionsVersion : '2.1.8'
|
|
14
|
+
jparkiePromiseVersion = project.hasProperty('jparkiePromiseVersion') ? rootProject.ext.jparkiePromiseVersion : '1.0.3'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
buildscript {
|
|
18
|
+
repositories {
|
|
19
|
+
google()
|
|
20
|
+
mavenCentral()
|
|
21
|
+
}
|
|
22
|
+
dependencies {
|
|
23
|
+
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
apply plugin: 'com.android.library'
|
|
28
|
+
|
|
29
|
+
android {
|
|
30
|
+
namespace = "com.josuelmm.capacitor.backgroundgeolocation"
|
|
31
|
+
compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
32
|
+
defaultConfig {
|
|
33
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
34
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
35
|
+
versionCode 1
|
|
36
|
+
versionName "0.1.0"
|
|
37
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
38
|
+
}
|
|
39
|
+
buildTypes {
|
|
40
|
+
release {
|
|
41
|
+
minifyEnabled false
|
|
42
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
lintOptions {
|
|
46
|
+
abortOnError false
|
|
47
|
+
}
|
|
48
|
+
compileOptions {
|
|
49
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
50
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
repositories {
|
|
55
|
+
google()
|
|
56
|
+
mavenCentral()
|
|
57
|
+
// jparkie/promise lives on JitPack — required by the native core.
|
|
58
|
+
maven { url 'https://jitpack.io' }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
dependencies {
|
|
62
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
63
|
+
implementation project(':capacitor-android')
|
|
64
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
65
|
+
implementation "androidx.localbroadcastmanager:localbroadcastmanager:$androidxLocalbroadcastmanagerVersion"
|
|
66
|
+
implementation "androidx.work:work-runtime:$androidxWorkRuntimeVersion"
|
|
67
|
+
implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
|
|
68
|
+
// Required by the copied com.marianhello.bgloc.* native core.
|
|
69
|
+
implementation "com.google.code.gson:gson:$gsonVersion"
|
|
70
|
+
implementation "org.slf4j:slf4j-api:$slf4jVersion"
|
|
71
|
+
implementation "com.github.tony19:logback-android:$logbackAndroidVersion"
|
|
72
|
+
implementation("io.github.nishkarsh:android-permissions:$androidPermissionsVersion") {
|
|
73
|
+
exclude group: 'com.android.support', module: 'appcompat-v7'
|
|
74
|
+
}
|
|
75
|
+
implementation "com.github.jparkie:promise:$jparkiePromiseVersion"
|
|
76
|
+
testImplementation "junit:junit:$junitVersion"
|
|
77
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
78
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Phase 1 — empty proguard rules. To be expanded in later phases.
|