@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,636 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MAURConfig.m
|
|
3
|
+
// BackgroundGeolocation
|
|
4
|
+
//
|
|
5
|
+
// Created by Marian Hello on 11/06/16.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "MAURConfig.h"
|
|
9
|
+
|
|
10
|
+
#define isNull(value) (value == nil || value == (id)[NSNull null])
|
|
11
|
+
#define isNotNull(value) (value != nil && value != (id)[NSNull null])
|
|
12
|
+
|
|
13
|
+
@implementation MAURConfig
|
|
14
|
+
|
|
15
|
+
@synthesize stationaryRadius, distanceFilter, desiredAccuracy, _debug, activityType, activitiesInterval, _stopOnTerminate, url, syncUrl, syncThreshold, syncEnabled, httpHeaders, httpMethod, syncHttpMethod, httpMode, syncMode, queryParams, _showsBackgroundLocationIndicator, heartbeatInterval, mockLocationPolicy, drivingEvents, includeBattery, activityConfidenceThreshold, maxAcceptedAccuracy, _saveBatteryOnBackground, maxLocations, _pauseLocationUpdates, locationProvider, _template;
|
|
16
|
+
|
|
17
|
+
-(instancetype) initWithDefaults {
|
|
18
|
+
self = [super init];
|
|
19
|
+
|
|
20
|
+
if (self == nil) {
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
stationaryRadius = [NSNumber numberWithInt:50];
|
|
25
|
+
distanceFilter = [NSNumber numberWithInt:500];
|
|
26
|
+
desiredAccuracy = [NSNumber numberWithInt:100];
|
|
27
|
+
_debug = [NSNumber numberWithBool:NO];
|
|
28
|
+
activityType = @"OtherNavigation";
|
|
29
|
+
activitiesInterval = [NSNumber numberWithInt:10000];
|
|
30
|
+
_stopOnTerminate = [NSNumber numberWithBool:YES];
|
|
31
|
+
_saveBatteryOnBackground = [NSNumber numberWithBool:NO];
|
|
32
|
+
maxLocations = [NSNumber numberWithInt:10000];
|
|
33
|
+
syncThreshold = [NSNumber numberWithInt:100];
|
|
34
|
+
syncEnabled = [NSNumber numberWithBool:YES];
|
|
35
|
+
_pauseLocationUpdates = [NSNumber numberWithBool:NO];
|
|
36
|
+
locationProvider = [NSNumber numberWithInt:DISTANCE_FILTER_PROVIDER];
|
|
37
|
+
httpMethod = @"POST";
|
|
38
|
+
syncHttpMethod = @"POST";
|
|
39
|
+
httpMode = @"batch";
|
|
40
|
+
syncMode = @"batch";
|
|
41
|
+
heartbeatInterval = [NSNumber numberWithInt:0];
|
|
42
|
+
mockLocationPolicy = @"allow";
|
|
43
|
+
// v4.5.2 — match Android defaults so the JS layer sees the same behavior
|
|
44
|
+
// regardless of platform when the host doesn't override these.
|
|
45
|
+
activityConfidenceThreshold = [NSNumber numberWithInt:50];
|
|
46
|
+
maxAcceptedAccuracy = nil; // off by default
|
|
47
|
+
// template =
|
|
48
|
+
|
|
49
|
+
return self;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
+(instancetype) fromDictionary:(NSDictionary*)config
|
|
53
|
+
{
|
|
54
|
+
MAURConfig *instance = [[MAURConfig alloc] init];
|
|
55
|
+
|
|
56
|
+
if (isNotNull(config[@"stationaryRadius"])) {
|
|
57
|
+
instance.stationaryRadius = config[@"stationaryRadius"];
|
|
58
|
+
}
|
|
59
|
+
if (isNotNull(config[@"distanceFilter"])) {
|
|
60
|
+
instance.distanceFilter = config[@"distanceFilter"];
|
|
61
|
+
}
|
|
62
|
+
if (isNotNull(config[@"desiredAccuracy"])) {
|
|
63
|
+
instance.desiredAccuracy = config[@"desiredAccuracy"];
|
|
64
|
+
}
|
|
65
|
+
if (isNotNull(config[@"debug"])) {
|
|
66
|
+
instance._debug = config[@"debug"];
|
|
67
|
+
}
|
|
68
|
+
if (isNotNull(config[@"activityType"])) {
|
|
69
|
+
instance.activityType = config[@"activityType"];
|
|
70
|
+
}
|
|
71
|
+
if (isNotNull(config[@"activitiesInterval"])) {
|
|
72
|
+
instance.activitiesInterval = config[@"activitiesInterval"];
|
|
73
|
+
}
|
|
74
|
+
if (isNotNull(config[@"stopOnTerminate"])) {
|
|
75
|
+
instance._stopOnTerminate = config[@"stopOnTerminate"];
|
|
76
|
+
}
|
|
77
|
+
if (config[@"url"] != nil) {
|
|
78
|
+
instance.url = config[@"url"];
|
|
79
|
+
}
|
|
80
|
+
if (config[@"syncUrl"] != nil) {
|
|
81
|
+
instance.syncUrl = config[@"syncUrl"];
|
|
82
|
+
}
|
|
83
|
+
if (isNotNull(config[@"syncThreshold"])) {
|
|
84
|
+
instance.syncThreshold = config[@"syncThreshold"];
|
|
85
|
+
}
|
|
86
|
+
if (isNotNull(config[@"sync"])) {
|
|
87
|
+
instance.syncEnabled = config[@"sync"];
|
|
88
|
+
}
|
|
89
|
+
if (config[@"httpHeaders"] != nil) {
|
|
90
|
+
instance.httpHeaders = config[@"httpHeaders"];
|
|
91
|
+
}
|
|
92
|
+
// headers (alias of httpHeaders)
|
|
93
|
+
if (config[@"headers"] != nil) {
|
|
94
|
+
instance.httpHeaders = config[@"headers"];
|
|
95
|
+
}
|
|
96
|
+
// v3.3 Phase 2: HTTP transport
|
|
97
|
+
if (isNotNull(config[@"httpMethod"])) {
|
|
98
|
+
instance.httpMethod = [(NSString*)config[@"httpMethod"] uppercaseString];
|
|
99
|
+
}
|
|
100
|
+
if (isNotNull(config[@"syncHttpMethod"])) {
|
|
101
|
+
instance.syncHttpMethod = [(NSString*)config[@"syncHttpMethod"] uppercaseString];
|
|
102
|
+
}
|
|
103
|
+
if (isNotNull(config[@"httpMode"])) {
|
|
104
|
+
instance.httpMode = [(NSString*)config[@"httpMode"] lowercaseString];
|
|
105
|
+
}
|
|
106
|
+
if (isNotNull(config[@"syncMode"])) {
|
|
107
|
+
instance.syncMode = [(NSString*)config[@"syncMode"] lowercaseString];
|
|
108
|
+
}
|
|
109
|
+
if (config[@"queryParams"] != nil) {
|
|
110
|
+
instance.queryParams = config[@"queryParams"];
|
|
111
|
+
}
|
|
112
|
+
if (isNotNull(config[@"showsBackgroundLocationIndicator"])) {
|
|
113
|
+
instance._showsBackgroundLocationIndicator = config[@"showsBackgroundLocationIndicator"];
|
|
114
|
+
}
|
|
115
|
+
if (isNotNull(config[@"heartbeatInterval"])) {
|
|
116
|
+
instance.heartbeatInterval = config[@"heartbeatInterval"];
|
|
117
|
+
}
|
|
118
|
+
if (isNotNull(config[@"mockLocationPolicy"])) {
|
|
119
|
+
instance.mockLocationPolicy = [(NSString*)config[@"mockLocationPolicy"] lowercaseString];
|
|
120
|
+
}
|
|
121
|
+
if ([config[@"drivingEvents"] isKindOfClass:[NSDictionary class]]) {
|
|
122
|
+
instance.drivingEvents = config[@"drivingEvents"];
|
|
123
|
+
}
|
|
124
|
+
if (isNotNull(config[@"includeBattery"])) {
|
|
125
|
+
instance.includeBattery = config[@"includeBattery"];
|
|
126
|
+
}
|
|
127
|
+
// v4.5.2 provider hardening
|
|
128
|
+
if (isNotNull(config[@"activityConfidenceThreshold"])) {
|
|
129
|
+
instance.activityConfidenceThreshold = config[@"activityConfidenceThreshold"];
|
|
130
|
+
}
|
|
131
|
+
if (isNotNull(config[@"maxAcceptedAccuracy"])) {
|
|
132
|
+
instance.maxAcceptedAccuracy = config[@"maxAcceptedAccuracy"];
|
|
133
|
+
}
|
|
134
|
+
if (isNotNull(config[@"saveBatteryOnBackground"])) {
|
|
135
|
+
instance._saveBatteryOnBackground = config[@"saveBatteryOnBackground"];
|
|
136
|
+
}
|
|
137
|
+
if (isNotNull(config[@"maxLocations"])) {
|
|
138
|
+
instance.maxLocations = config[@"maxLocations"];
|
|
139
|
+
}
|
|
140
|
+
if (isNotNull(config[@"pauseLocationUpdates"])) {
|
|
141
|
+
instance._pauseLocationUpdates = config[@"pauseLocationUpdates"];
|
|
142
|
+
}
|
|
143
|
+
if (isNotNull(config[@"locationProvider"])) {
|
|
144
|
+
instance.locationProvider = config[@"locationProvider"];
|
|
145
|
+
}
|
|
146
|
+
if (config[@"postTemplate"] != nil) {
|
|
147
|
+
instance._template = config[@"postTemplate"];
|
|
148
|
+
}
|
|
149
|
+
// bodyTemplate (alias of postTemplate)
|
|
150
|
+
if (config[@"bodyTemplate"] != nil) {
|
|
151
|
+
instance._template = config[@"bodyTemplate"];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return instance;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
+ (instancetype) merge:(MAURConfig*)config withConfig:(MAURConfig*)newConfig
|
|
158
|
+
{
|
|
159
|
+
if (config == nil) {
|
|
160
|
+
return newConfig;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (newConfig == nil) {
|
|
164
|
+
return config;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
MAURConfig *merger= [config copy];
|
|
168
|
+
|
|
169
|
+
if ([newConfig hasStationaryRadius]) {
|
|
170
|
+
merger.stationaryRadius = newConfig.stationaryRadius;
|
|
171
|
+
}
|
|
172
|
+
if ([newConfig hasDistanceFilter]) {
|
|
173
|
+
merger.distanceFilter = newConfig.distanceFilter;
|
|
174
|
+
}
|
|
175
|
+
if ([newConfig hasDesiredAccuracy]) {
|
|
176
|
+
merger.desiredAccuracy = newConfig.desiredAccuracy;
|
|
177
|
+
}
|
|
178
|
+
if ([newConfig hasDebug]) {
|
|
179
|
+
merger._debug = newConfig._debug;
|
|
180
|
+
}
|
|
181
|
+
if ([newConfig hasActivityType]) {
|
|
182
|
+
merger.activityType = newConfig.activityType;
|
|
183
|
+
}
|
|
184
|
+
if ([newConfig hasActivitiesInterval]) {
|
|
185
|
+
merger.activitiesInterval = newConfig.activitiesInterval;
|
|
186
|
+
}
|
|
187
|
+
if ([newConfig hasStopOnTerminate]) {
|
|
188
|
+
merger._stopOnTerminate = newConfig._stopOnTerminate;
|
|
189
|
+
}
|
|
190
|
+
if ([newConfig hasUrl]) {
|
|
191
|
+
merger.url = newConfig.url;
|
|
192
|
+
}
|
|
193
|
+
if ([newConfig hasSyncUrl]) {
|
|
194
|
+
merger.syncUrl = newConfig.syncUrl;
|
|
195
|
+
}
|
|
196
|
+
if ([newConfig hasSyncThreshold]) {
|
|
197
|
+
merger.syncThreshold = newConfig.syncThreshold;
|
|
198
|
+
}
|
|
199
|
+
if ([newConfig hasSyncEnabled]) {
|
|
200
|
+
merger.syncEnabled = [NSNumber numberWithBool:[newConfig syncEnabled]];
|
|
201
|
+
}
|
|
202
|
+
if ([newConfig hasHttpHeaders]) {
|
|
203
|
+
merger.httpHeaders = newConfig.httpHeaders;
|
|
204
|
+
}
|
|
205
|
+
if (newConfig.httpMethod != nil) {
|
|
206
|
+
merger.httpMethod = newConfig.httpMethod;
|
|
207
|
+
}
|
|
208
|
+
if (newConfig.syncHttpMethod != nil) {
|
|
209
|
+
merger.syncHttpMethod = newConfig.syncHttpMethod;
|
|
210
|
+
}
|
|
211
|
+
if (newConfig.httpMode != nil) {
|
|
212
|
+
merger.httpMode = newConfig.httpMode;
|
|
213
|
+
}
|
|
214
|
+
if (newConfig.syncMode != nil) {
|
|
215
|
+
merger.syncMode = newConfig.syncMode;
|
|
216
|
+
}
|
|
217
|
+
if (newConfig.queryParams != nil) {
|
|
218
|
+
merger.queryParams = newConfig.queryParams;
|
|
219
|
+
}
|
|
220
|
+
if ([newConfig hasShowsBackgroundLocationIndicator]) {
|
|
221
|
+
merger._showsBackgroundLocationIndicator = newConfig._showsBackgroundLocationIndicator;
|
|
222
|
+
}
|
|
223
|
+
if (newConfig.heartbeatInterval != nil) {
|
|
224
|
+
merger.heartbeatInterval = newConfig.heartbeatInterval;
|
|
225
|
+
}
|
|
226
|
+
if (newConfig.mockLocationPolicy != nil) {
|
|
227
|
+
merger.mockLocationPolicy = newConfig.mockLocationPolicy;
|
|
228
|
+
}
|
|
229
|
+
if (newConfig.drivingEvents != nil) {
|
|
230
|
+
merger.drivingEvents = newConfig.drivingEvents;
|
|
231
|
+
}
|
|
232
|
+
if (newConfig.includeBattery != nil) {
|
|
233
|
+
merger.includeBattery = newConfig.includeBattery;
|
|
234
|
+
}
|
|
235
|
+
if (newConfig.activityConfidenceThreshold != nil) {
|
|
236
|
+
merger.activityConfidenceThreshold = newConfig.activityConfidenceThreshold;
|
|
237
|
+
}
|
|
238
|
+
if (newConfig.maxAcceptedAccuracy != nil) {
|
|
239
|
+
merger.maxAcceptedAccuracy = newConfig.maxAcceptedAccuracy;
|
|
240
|
+
}
|
|
241
|
+
if ([newConfig hasSaveBatteryOnBackground]) {
|
|
242
|
+
merger._saveBatteryOnBackground = newConfig._saveBatteryOnBackground;
|
|
243
|
+
}
|
|
244
|
+
if ([newConfig hasMaxLocations]) {
|
|
245
|
+
merger.maxLocations = newConfig.maxLocations;
|
|
246
|
+
}
|
|
247
|
+
if ([newConfig hasPauseLocationUpdates]) {
|
|
248
|
+
merger._pauseLocationUpdates = newConfig._pauseLocationUpdates;
|
|
249
|
+
}
|
|
250
|
+
if ([newConfig hasLocationProvider]) {
|
|
251
|
+
merger.locationProvider = newConfig.locationProvider;
|
|
252
|
+
}
|
|
253
|
+
if ([newConfig hasTemplate]) {
|
|
254
|
+
merger._template = newConfig._template;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return merger;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
-(id) copyWithZone: (NSZone *) zone
|
|
261
|
+
{
|
|
262
|
+
MAURConfig *copy = [[[self class] allocWithZone: zone] init];
|
|
263
|
+
if (copy) {
|
|
264
|
+
copy.stationaryRadius = stationaryRadius;
|
|
265
|
+
copy.distanceFilter = distanceFilter;
|
|
266
|
+
copy.desiredAccuracy = desiredAccuracy;
|
|
267
|
+
copy._debug = _debug;
|
|
268
|
+
copy.activityType = activityType;
|
|
269
|
+
copy.activitiesInterval = activitiesInterval;
|
|
270
|
+
copy._stopOnTerminate = _stopOnTerminate;
|
|
271
|
+
copy.url = url;
|
|
272
|
+
copy.syncUrl = syncUrl;
|
|
273
|
+
copy.syncThreshold = syncThreshold;
|
|
274
|
+
copy.syncEnabled = syncEnabled;
|
|
275
|
+
copy.httpHeaders = httpHeaders;
|
|
276
|
+
copy.httpMethod = httpMethod;
|
|
277
|
+
copy.syncHttpMethod = syncHttpMethod;
|
|
278
|
+
copy.httpMode = httpMode;
|
|
279
|
+
copy.syncMode = syncMode;
|
|
280
|
+
copy.queryParams = queryParams;
|
|
281
|
+
copy._showsBackgroundLocationIndicator = _showsBackgroundLocationIndicator;
|
|
282
|
+
copy.heartbeatInterval = heartbeatInterval;
|
|
283
|
+
copy.mockLocationPolicy = mockLocationPolicy;
|
|
284
|
+
copy.drivingEvents = drivingEvents;
|
|
285
|
+
copy.includeBattery = includeBattery;
|
|
286
|
+
copy.activityConfidenceThreshold = activityConfidenceThreshold;
|
|
287
|
+
copy.maxAcceptedAccuracy = maxAcceptedAccuracy;
|
|
288
|
+
copy._saveBatteryOnBackground = _saveBatteryOnBackground;
|
|
289
|
+
copy.maxLocations = maxLocations;
|
|
290
|
+
copy._pauseLocationUpdates = _pauseLocationUpdates;
|
|
291
|
+
copy.locationProvider = locationProvider;
|
|
292
|
+
copy._template = _template;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return copy;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
- (BOOL) hasStationaryRadius
|
|
299
|
+
{
|
|
300
|
+
return stationaryRadius != nil;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
- (BOOL) hasDistanceFilter
|
|
304
|
+
{
|
|
305
|
+
return distanceFilter != nil;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
- (BOOL) hasDesiredAccuracy
|
|
309
|
+
{
|
|
310
|
+
return desiredAccuracy != nil;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
- (BOOL) hasDebug
|
|
314
|
+
{
|
|
315
|
+
return _debug != nil;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
- (BOOL) hasActivityType
|
|
319
|
+
{
|
|
320
|
+
return activityType != nil;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
- (BOOL) hasActivitiesInterval
|
|
324
|
+
{
|
|
325
|
+
return activitiesInterval != nil;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
- (BOOL) hasStopOnTerminate
|
|
329
|
+
{
|
|
330
|
+
return _stopOnTerminate != nil;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
- (BOOL) hasUrl
|
|
334
|
+
{
|
|
335
|
+
return url != nil;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
- (BOOL) hasValidUrl
|
|
339
|
+
{
|
|
340
|
+
return url != nil && url.length > 0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
- (void) setUrl:(NSString*)newUrl
|
|
344
|
+
{
|
|
345
|
+
if (newUrl == (id)[NSNull null]) {
|
|
346
|
+
url = @"";
|
|
347
|
+
} else {
|
|
348
|
+
url = newUrl;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
- (NSString*) url
|
|
353
|
+
{
|
|
354
|
+
if (url == nil) {
|
|
355
|
+
url = @"";
|
|
356
|
+
}
|
|
357
|
+
return url;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
- (BOOL) hasSyncUrl
|
|
361
|
+
{
|
|
362
|
+
return syncUrl != nil;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
- (BOOL) hasValidSyncUrl
|
|
366
|
+
{
|
|
367
|
+
return syncUrl != nil && syncUrl.length > 0;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
- (void) setSyncUrl:(NSString*)newSyncUrl
|
|
371
|
+
{
|
|
372
|
+
if (newSyncUrl == (id)[NSNull null]) {
|
|
373
|
+
syncUrl = @"";
|
|
374
|
+
} else {
|
|
375
|
+
syncUrl = newSyncUrl;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
- (NSString*) syncUrl
|
|
380
|
+
{
|
|
381
|
+
if (syncUrl == nil) {
|
|
382
|
+
syncUrl = @"";
|
|
383
|
+
}
|
|
384
|
+
return syncUrl;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
- (BOOL) hasSyncThreshold
|
|
388
|
+
{
|
|
389
|
+
return syncThreshold != nil;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
- (BOOL) hasSyncEnabled
|
|
393
|
+
{
|
|
394
|
+
return syncEnabled != nil;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
- (BOOL) syncEnabled
|
|
398
|
+
{
|
|
399
|
+
return syncEnabled == nil ? YES : [syncEnabled boolValue];
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
- (BOOL) hasHttpHeaders
|
|
403
|
+
{
|
|
404
|
+
return httpHeaders != nil;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
- (void) setHttpHeaders:(NSMutableDictionary *)newHttpHeaders
|
|
408
|
+
{
|
|
409
|
+
if (newHttpHeaders == (id)[NSNull null]) {
|
|
410
|
+
httpHeaders = [[NSMutableDictionary alloc] init];
|
|
411
|
+
} else {
|
|
412
|
+
httpHeaders = newHttpHeaders;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
- (NSMutableDictionary *) httpHeaders
|
|
417
|
+
{
|
|
418
|
+
if (httpHeaders == nil) {
|
|
419
|
+
httpHeaders = [[NSMutableDictionary alloc] init];
|
|
420
|
+
}
|
|
421
|
+
return httpHeaders;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
- (BOOL) hasSaveBatteryOnBackground
|
|
425
|
+
{
|
|
426
|
+
return _saveBatteryOnBackground != nil;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
- (BOOL) hasShowsBackgroundLocationIndicator
|
|
430
|
+
{
|
|
431
|
+
return _showsBackgroundLocationIndicator != nil;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
- (BOOL) showsBackgroundLocationIndicator
|
|
435
|
+
{
|
|
436
|
+
return _showsBackgroundLocationIndicator != nil ? [_showsBackgroundLocationIndicator boolValue] : NO;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
- (BOOL) hasMaxLocations
|
|
440
|
+
{
|
|
441
|
+
return maxLocations != nil;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
- (BOOL) hasPauseLocationUpdates
|
|
445
|
+
{
|
|
446
|
+
return _pauseLocationUpdates != nil;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
- (BOOL) hasLocationProvider
|
|
450
|
+
{
|
|
451
|
+
return locationProvider != nil;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
- (BOOL) hasTemplate
|
|
455
|
+
{
|
|
456
|
+
return _template != nil;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
- (void) set_template:(NSObject*)template
|
|
460
|
+
{
|
|
461
|
+
if (template == (id)[NSNull null]) {
|
|
462
|
+
_template = [MAURConfig getDefaultTemplate];
|
|
463
|
+
} else {
|
|
464
|
+
_template = template;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
- (NSObject*) _template{
|
|
469
|
+
if (_template == nil) {
|
|
470
|
+
_template = [MAURConfig getDefaultTemplate];
|
|
471
|
+
}
|
|
472
|
+
return _template;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
- (BOOL) isDebugging
|
|
476
|
+
{
|
|
477
|
+
return _debug.boolValue;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
- (BOOL) stopOnTerminate
|
|
481
|
+
{
|
|
482
|
+
return _stopOnTerminate.boolValue;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
- (BOOL) saveBatteryOnBackground
|
|
486
|
+
{
|
|
487
|
+
return _saveBatteryOnBackground.boolValue;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
- (BOOL) pauseLocationUpdates
|
|
491
|
+
{
|
|
492
|
+
return _pauseLocationUpdates.boolValue;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
- (CLActivityType) decodeActivityType
|
|
496
|
+
{
|
|
497
|
+
if ([activityType caseInsensitiveCompare:@"AutomotiveNavigation"] == NSOrderedSame) {
|
|
498
|
+
return CLActivityTypeAutomotiveNavigation;
|
|
499
|
+
}
|
|
500
|
+
if ([activityType caseInsensitiveCompare:@"OtherNavigation"] == NSOrderedSame) {
|
|
501
|
+
return CLActivityTypeOtherNavigation;
|
|
502
|
+
}
|
|
503
|
+
if ([activityType caseInsensitiveCompare:@"Fitness"] == NSOrderedSame) {
|
|
504
|
+
return CLActivityTypeFitness;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return CLActivityTypeOther;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
- (NSInteger) decodeDesiredAccuracy
|
|
511
|
+
{
|
|
512
|
+
NSInteger desiredAccuracy = self.desiredAccuracy.integerValue;
|
|
513
|
+
|
|
514
|
+
if (desiredAccuracy >= 1000) {
|
|
515
|
+
return kCLLocationAccuracyKilometer;
|
|
516
|
+
}
|
|
517
|
+
if (desiredAccuracy >= 100) {
|
|
518
|
+
return kCLLocationAccuracyHundredMeters;
|
|
519
|
+
}
|
|
520
|
+
if (desiredAccuracy >= 10) {
|
|
521
|
+
return kCLLocationAccuracyNearestTenMeters;
|
|
522
|
+
}
|
|
523
|
+
if (desiredAccuracy >= 0) {
|
|
524
|
+
return kCLLocationAccuracyBest;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return kCLLocationAccuracyHundredMeters;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
+ (NSDictionary*) getDefaultTemplate
|
|
531
|
+
{
|
|
532
|
+
return @{
|
|
533
|
+
@"time": @"@time",
|
|
534
|
+
@"accuracy": @"@accuracy",
|
|
535
|
+
@"altitudeAccuracy": @"@altitudeAccuracy",
|
|
536
|
+
@"speed": @"@speed",
|
|
537
|
+
@"bearing": @"@bearing",
|
|
538
|
+
@"altitude": @"@altitude",
|
|
539
|
+
@"latitude": @"@latitude",
|
|
540
|
+
@"longitude": @"@longitude",
|
|
541
|
+
@"provider": @"@provider", // v4.5.1 — was literal "provider" (bug)
|
|
542
|
+
@"locationProvider": @"@locationProvider",
|
|
543
|
+
@"radius": @"@radius",
|
|
544
|
+
// v4.5.1 — README promete events/battery/isCharging en payload default. Sin esto,
|
|
545
|
+
// el template default que se usa siempre que la app no configura postTemplate omitía
|
|
546
|
+
// estos campos al serializar via toResultFromTemplate.
|
|
547
|
+
@"events": @"@events",
|
|
548
|
+
@"battery": @"@battery",
|
|
549
|
+
@"isCharging": @"@isCharging",
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
- (NSString*) getHttpHeadersAsString:(NSError * __autoreleasing *)outError;
|
|
554
|
+
{
|
|
555
|
+
NSError *error = nil;
|
|
556
|
+
NSString *httpHeadersString;
|
|
557
|
+
|
|
558
|
+
if ([self hasHttpHeaders]) {
|
|
559
|
+
NSData *jsonHttpHeaders = [NSJSONSerialization dataWithJSONObject:httpHeaders options:NSJSONWritingPrettyPrinted error:&error];
|
|
560
|
+
if (jsonHttpHeaders) {
|
|
561
|
+
httpHeadersString = [[NSString alloc] initWithData:jsonHttpHeaders encoding:NSUTF8StringEncoding];
|
|
562
|
+
} else {
|
|
563
|
+
if (outError != nil) {
|
|
564
|
+
NSLog(@"Http headers serialization error: %@", error);
|
|
565
|
+
*outError = error;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return httpHeadersString;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
- (NSString*) getTemplateAsString:(NSError * __autoreleasing *)outError;
|
|
574
|
+
{
|
|
575
|
+
NSError *error = nil;
|
|
576
|
+
NSString *templateAsString;
|
|
577
|
+
|
|
578
|
+
if ([self hasTemplate]) {
|
|
579
|
+
NSData *jsonTemplate = [NSJSONSerialization dataWithJSONObject:_template options:0 error:&error];
|
|
580
|
+
if (jsonTemplate) {
|
|
581
|
+
templateAsString = [[NSString alloc] initWithData:jsonTemplate encoding:NSUTF8StringEncoding];
|
|
582
|
+
} else {
|
|
583
|
+
if (outError != nil) {
|
|
584
|
+
NSLog(@"Template serialization error: %@", error);
|
|
585
|
+
*outError = error;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
return templateAsString;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
- (NSDictionary*) toDictionary
|
|
594
|
+
{
|
|
595
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:10];
|
|
596
|
+
|
|
597
|
+
if ([self hasActivityType]) [dict setObject:self.activityType forKey:@"activityType"];
|
|
598
|
+
if ([self hasActivitiesInterval]) [dict setObject:self.activitiesInterval forKey:@"activitiesInterval"];
|
|
599
|
+
if ([self hasUrl]) [dict setObject:self.url forKey:@"url"];
|
|
600
|
+
if ([self hasSyncUrl]) [dict setObject:self.syncUrl forKey:@"syncUrl"];
|
|
601
|
+
if ([self hasHttpHeaders]) [dict setObject:self.httpHeaders forKey:@"httpHeaders"];
|
|
602
|
+
if (self.httpMethod != nil) [dict setObject:self.httpMethod forKey:@"httpMethod"];
|
|
603
|
+
if (self.syncHttpMethod != nil) [dict setObject:self.syncHttpMethod forKey:@"syncHttpMethod"];
|
|
604
|
+
if (self.httpMode != nil) [dict setObject:self.httpMode forKey:@"httpMode"];
|
|
605
|
+
if (self.syncMode != nil) [dict setObject:self.syncMode forKey:@"syncMode"];
|
|
606
|
+
if (self.queryParams != nil) [dict setObject:self.queryParams forKey:@"queryParams"];
|
|
607
|
+
if ([self hasShowsBackgroundLocationIndicator]) [dict setObject:self._showsBackgroundLocationIndicator forKey:@"showsBackgroundLocationIndicator"];
|
|
608
|
+
if (self.heartbeatInterval != nil) [dict setObject:self.heartbeatInterval forKey:@"heartbeatInterval"];
|
|
609
|
+
if (self.mockLocationPolicy != nil) [dict setObject:self.mockLocationPolicy forKey:@"mockLocationPolicy"];
|
|
610
|
+
if (self.drivingEvents != nil) [dict setObject:self.drivingEvents forKey:@"drivingEvents"];
|
|
611
|
+
if (self.includeBattery != nil) [dict setObject:self.includeBattery forKey:@"includeBattery"];
|
|
612
|
+
if (self.activityConfidenceThreshold != nil) [dict setObject:self.activityConfidenceThreshold forKey:@"activityConfidenceThreshold"];
|
|
613
|
+
if (self.maxAcceptedAccuracy != nil) [dict setObject:self.maxAcceptedAccuracy forKey:@"maxAcceptedAccuracy"];
|
|
614
|
+
if ([self hasStationaryRadius]) [dict setObject:self.stationaryRadius forKey:@"stationaryRadius"];
|
|
615
|
+
if ([self hasDistanceFilter]) [dict setObject:self.distanceFilter forKey:@"distanceFilter"];
|
|
616
|
+
if ([self hasDesiredAccuracy]) [dict setObject:self.desiredAccuracy forKey:@"desiredAccuracy"];
|
|
617
|
+
if ([self hasDebug]) [dict setObject:self._debug forKey:@"debug"];
|
|
618
|
+
if ([self hasStopOnTerminate]) [dict setObject:self._stopOnTerminate forKey:@"stopOnTerminate"];
|
|
619
|
+
if ([self hasSyncThreshold]) [dict setObject:self.syncThreshold forKey:@"syncThreshold"];
|
|
620
|
+
if ([self hasSyncEnabled]) [dict setObject:syncEnabled forKey:@"sync"];
|
|
621
|
+
if ([self hasSaveBatteryOnBackground]) [dict setObject:self._saveBatteryOnBackground forKey:@"saveBatteryOnBackground"];
|
|
622
|
+
if ([self hasMaxLocations]) [dict setObject:self.maxLocations forKey:@"maxLocations"];
|
|
623
|
+
if ([self hasPauseLocationUpdates]) [dict setObject:self._pauseLocationUpdates forKey:@"pauseLocationUpdates"];
|
|
624
|
+
if ([self hasLocationProvider]) [dict setObject:self.locationProvider forKey:@"locationProvider"];
|
|
625
|
+
[dict setObject:self._template forKey:@"postTemplate"];
|
|
626
|
+
|
|
627
|
+
return dict;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
- (NSString *) description
|
|
631
|
+
{
|
|
632
|
+
return [NSString stringWithFormat:@"Config: distanceFilter=%@ stationaryRadius=%@ desiredAccuracy=%@ activityType=%@ activitiesInterval=%@ isDebugging=%@ stopOnTerminate=%@ url=%@ syncThreshold=%@ maxLocations=%@ httpHeaders=%@ pauseLocationUpdates=%@ saveBatteryOnBackground=%@ locationProvider=%@ postTemplate=%@", self.distanceFilter, self.stationaryRadius, self.desiredAccuracy, self.activityType, self.activitiesInterval, self._debug, self._stopOnTerminate, self.url, self.syncThreshold, self.maxLocations, self.httpHeaders, self._pauseLocationUpdates, self._saveBatteryOnBackground, self.locationProvider, self._template];
|
|
633
|
+
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
@end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MAURConfigurationContract.h
|
|
3
|
+
// BackgroundGeolocation
|
|
4
|
+
//
|
|
5
|
+
// Created by Marian Hello on 01/12/2017.
|
|
6
|
+
// Copyright © 2017 mauron85. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifndef MAURConfigurationContract_h
|
|
10
|
+
#define MAURConfigurationContract_h
|
|
11
|
+
|
|
12
|
+
#define CC_TABLE_NAME "configuration"
|
|
13
|
+
#define CC_COLUMN_NAME_ID "id"
|
|
14
|
+
#define CC_COLUMN_NAME_NULLABLE "NULLHACK"
|
|
15
|
+
#define CC_COLUMN_NAME_RADIUS "stationary_radius"
|
|
16
|
+
#define CC_COLUMN_NAME_DISTANCE_FILTER "distance_filter"
|
|
17
|
+
#define CC_COLUMN_NAME_DESIRED_ACCURACY "desired_accuracy"
|
|
18
|
+
#define CC_COLUMN_NAME_DEBUG "debugging"
|
|
19
|
+
#define CC_COLUMN_NAME_ACTIVITY_TYPE "activity_type"
|
|
20
|
+
#define CC_COLUMN_NAME_NOTIF_TITLE "notification_title"
|
|
21
|
+
#define CC_COLUMN_NAME_NOTIF_TEXT "notification_text"
|
|
22
|
+
#define CC_COLUMN_NAME_NOTIF_ICON_LARGE "notification_icon_large"
|
|
23
|
+
#define CC_COLUMN_NAME_NOTIF_ICON_SMALL "notification_icon_small"
|
|
24
|
+
#define CC_COLUMN_NAME_NOTIF_COLOR "notification_icon_color"
|
|
25
|
+
#define CC_COLUMN_NAME_STOP_TERMINATE "stop_terminate"
|
|
26
|
+
#define CC_COLUMN_NAME_START_BOOT "start_boot"
|
|
27
|
+
#define CC_COLUMN_NAME_START_FOREGROUND "start_foreground"
|
|
28
|
+
#define CC_COLUMN_NAME_STOP_ON_STILL "stop_still"
|
|
29
|
+
#define CC_COLUMN_NAME_LOCATION_PROVIDER "service_provider"
|
|
30
|
+
#define CC_COLUMN_NAME_INTERVAL "interval"
|
|
31
|
+
#define CC_COLUMN_NAME_FASTEST_INTERVAL "fastest_interval"
|
|
32
|
+
#define CC_COLUMN_NAME_ACTIVITIES_INTERVAL "activities_interval"
|
|
33
|
+
#define CC_COLUMN_NAME_URL "url"
|
|
34
|
+
#define CC_COLUMN_NAME_SYNC_URL "sync_url"
|
|
35
|
+
#define CC_COLUMN_NAME_SYNC_THRESHOLD "sync_threshold"
|
|
36
|
+
#define CC_COLUMN_NAME_SYNC_ENABLED "sync_enabled"
|
|
37
|
+
#define CC_COLUMN_NAME_HEADERS "http_headers"
|
|
38
|
+
#define CC_COLUMN_NAME_SAVE_BATTERY "save_battery"
|
|
39
|
+
#define CC_COLUMN_NAME_MAX_LOCATIONS "max_locations"
|
|
40
|
+
#define CC_COLUMN_NAME_PAUSE_LOCATION_UPDATES "pause_updates"
|
|
41
|
+
#define CC_COLUMN_NAME_TEMPLATE "template"
|
|
42
|
+
#define CC_COLUMN_NAME_LAST_UPDATED_AT "updated_at"
|
|
43
|
+
// v4.5: full Config JSON blob — paridad con Android. Storage of post-3.2 keys without
|
|
44
|
+
// new per-field columns (httpMethod, queryParams, drivingEvents, includeBattery, ...).
|
|
45
|
+
#define CC_COLUMN_NAME_CONFIG_JSON "config_json"
|
|
46
|
+
|
|
47
|
+
@interface MAURConfigurationContract : NSObject
|
|
48
|
+
|
|
49
|
+
+ (NSString*) createTableSQL;
|
|
50
|
+
|
|
51
|
+
@end
|
|
52
|
+
|
|
53
|
+
#endif /* MAURConfigurationContract_h */
|