@transistorsoft/capacitor-background-geolocation 8.0.1 → 9.0.1
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/Package.swift +10 -16
- package/README.md +99 -211
- package/TransistorsoftCapacitorBackgroundGeolocation.podspec +7 -5
- package/android/build.gradle +16 -54
- package/android/src/main/java/com/transistorsoft/bggeo/capacitor/BackgroundGeolocationPlugin.java +132 -70
- package/dist/index.js +198 -189
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs.js +255 -205
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1141 -1092
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.swift +353 -306
- package/package.json +14 -15
- package/src/index.d.ts +10 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +0 -13
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/maven-metadata.xml +0 -13
- package/dist/Events.js +0 -19
- package/dist/Events.js.map +0 -1
- package/dist/declarations/BackgroundGeolocation.d.ts +0 -1632
- package/dist/declarations/interfaces/Authorization.d.ts +0 -185
- package/dist/declarations/interfaces/AuthorizationEvent.d.ts +0 -34
- package/dist/declarations/interfaces/Config.d.ts +0 -2474
- package/dist/declarations/interfaces/ConnectivityChangeEvent.d.ts +0 -18
- package/dist/declarations/interfaces/CurrentPositionRequest.d.ts +0 -45
- package/dist/declarations/interfaces/DeviceInfo.d.ts +0 -33
- package/dist/declarations/interfaces/DeviceSettings.d.ts +0 -223
- package/dist/declarations/interfaces/Geofence.d.ts +0 -319
- package/dist/declarations/interfaces/GeofenceEvent.d.ts +0 -35
- package/dist/declarations/interfaces/GeofencesChangeEvent.d.ts +0 -22
- package/dist/declarations/interfaces/HeartbeatEvent.d.ts +0 -20
- package/dist/declarations/interfaces/HttpEvent.d.ts +0 -313
- package/dist/declarations/interfaces/Location.d.ts +0 -257
- package/dist/declarations/interfaces/LocationAuthorizationAlert.d.ts +0 -41
- package/dist/declarations/interfaces/Logger.d.ts +0 -359
- package/dist/declarations/interfaces/MotionActivityEvent.d.ts +0 -34
- package/dist/declarations/interfaces/MotionChangeEvent.d.ts +0 -15
- package/dist/declarations/interfaces/Notification.d.ts +0 -491
- package/dist/declarations/interfaces/PermissionRationale.d.ts +0 -31
- package/dist/declarations/interfaces/ProviderChangeEvent.d.ts +0 -74
- package/dist/declarations/interfaces/SQLQuery.d.ts +0 -60
- package/dist/declarations/interfaces/Sensors.d.ts +0 -31
- package/dist/declarations/interfaces/State.d.ts +0 -51
- package/dist/declarations/interfaces/Subscription.d.ts +0 -104
- package/dist/declarations/interfaces/TransistorAuthorizationToken.d.ts +0 -63
- package/dist/declarations/interfaces/WatchPositionRequest.d.ts +0 -45
- package/dist/declarations/types.d.ts +0 -188
- package/dist/index.d.ts +0 -3
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,62 +1,68 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@capacitor/core');
|
|
4
|
+
var backgroundGeolocationTypes = require('@transistorsoft/background-geolocation-types');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TERMINATE: "terminate",
|
|
8
|
-
LOCATION: "location",
|
|
9
|
-
HTTP: "http",
|
|
10
|
-
MOTIONCHANGE: "motionchange",
|
|
11
|
-
PROVIDERCHANGE: "providerchange",
|
|
12
|
-
HEARTBEAT: "heartbeat",
|
|
13
|
-
ACTIVITYCHANGE: "activitychange",
|
|
14
|
-
GEOFENCE: "geofence",
|
|
15
|
-
GEOFENCESCHANGE: "geofenceschange",
|
|
16
|
-
SCHEDULE: "schedule",
|
|
17
|
-
CONNECTIVITYCHANGE: "connectivitychange",
|
|
18
|
-
ENABLEDCHANGE: "enabledchange",
|
|
19
|
-
POWERSAVECHANGE: "powersavechange",
|
|
20
|
-
NOTIFICATIONACTION: "notificationaction",
|
|
21
|
-
AUTHORIZATION: "authorization",
|
|
22
|
-
};
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function __generator(thisArg, body) {
|
|
34
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
35
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
36
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
37
|
+
function step(op) {
|
|
38
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
39
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
40
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
41
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
42
|
+
switch (op[0]) {
|
|
43
|
+
case 0: case 1: t = op; break;
|
|
44
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
45
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
46
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
47
|
+
default:
|
|
48
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
49
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
50
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
51
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
52
|
+
if (t[2]) _.ops.pop();
|
|
53
|
+
_.trys.pop(); continue;
|
|
54
|
+
}
|
|
55
|
+
op = body.call(thisArg, _);
|
|
56
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
57
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : undefined, done: true };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
62
|
+
var e = new Error(message);
|
|
63
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
59
64
|
};
|
|
65
|
+
|
|
60
66
|
var NativeModule = core.registerPlugin('BackgroundGeolocation');
|
|
61
67
|
/**
|
|
62
68
|
* Logger
|
|
@@ -213,7 +219,10 @@ var TransistorAuthorizationToken = /** @class */ (function () {
|
|
|
213
219
|
return config;
|
|
214
220
|
var token = config.transistorAuthorizationToken;
|
|
215
221
|
delete config.transistorAuthorizationToken;
|
|
216
|
-
config.
|
|
222
|
+
if (!config.http) {
|
|
223
|
+
config.http = {};
|
|
224
|
+
}
|
|
225
|
+
config.http.url = token.url + LOCATIONS_PATH;
|
|
217
226
|
config.authorization = {
|
|
218
227
|
strategy: 'JWT',
|
|
219
228
|
accessToken: token.accessToken,
|
|
@@ -232,8 +241,10 @@ var TransistorAuthorizationToken = /** @class */ (function () {
|
|
|
232
241
|
var IGNORE_BATTERY_OPTIMIZATIONS = "IGNORE_BATTERY_OPTIMIZATIONS";
|
|
233
242
|
var POWER_MANAGER = "POWER_MANAGER";
|
|
234
243
|
var resolveSettingsRequest = function (resolve, request) {
|
|
235
|
-
|
|
236
|
-
|
|
244
|
+
// lastSeenAt arrives from the native bridge as a unix timestamp (number); convert to Date.
|
|
245
|
+
var lastSeenAt = request.lastSeenAt;
|
|
246
|
+
if (lastSeenAt > 0) {
|
|
247
|
+
request.lastSeenAt = new Date(lastSeenAt);
|
|
237
248
|
}
|
|
238
249
|
resolve(request);
|
|
239
250
|
};
|
|
@@ -284,8 +295,8 @@ var DeviceSettings = /** @class */ (function () {
|
|
|
284
295
|
var TAG = "TSLocationManager";
|
|
285
296
|
/// Container for event-subscriptions.
|
|
286
297
|
var EVENT_SUBSCRIPTIONS = [];
|
|
287
|
-
/// Container for
|
|
288
|
-
var WATCH_POSITION_SUBSCRIPTIONS =
|
|
298
|
+
/// Container for watchPosition subscriptions, keyed by watchId.
|
|
299
|
+
var WATCH_POSITION_SUBSCRIPTIONS = new Map();
|
|
289
300
|
/// Event handler Subscription
|
|
290
301
|
///
|
|
291
302
|
var Subscription = /** @class */ (function () {
|
|
@@ -296,148 +307,175 @@ var Subscription = /** @class */ (function () {
|
|
|
296
307
|
}
|
|
297
308
|
return Subscription;
|
|
298
309
|
}());
|
|
299
|
-
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var
|
|
324
|
-
var
|
|
325
|
-
var
|
|
326
|
-
var
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
var
|
|
330
|
-
var
|
|
331
|
-
var
|
|
332
|
-
var
|
|
333
|
-
var
|
|
334
|
-
var
|
|
335
|
-
var AUTHORIZATION_STATUS_NOT_DETERMINED = 0;
|
|
336
|
-
var AUTHORIZATION_STATUS_RESTRICTED = 1;
|
|
337
|
-
var AUTHORIZATION_STATUS_DENIED = 2;
|
|
338
|
-
var AUTHORIZATION_STATUS_ALWAYS = 3;
|
|
339
|
-
var AUTHORIZATION_STATUS_WHEN_IN_USE = 4;
|
|
340
|
-
var NOTIFICATION_PRIORITY_DEFAULT = 0;
|
|
341
|
-
var NOTIFICATION_PRIORITY_HIGH = 1;
|
|
342
|
-
var NOTIFICATION_PRIORITY_LOW = -1;
|
|
343
|
-
var NOTIFICATION_PRIORITY_MAX = 2;
|
|
344
|
-
var NOTIFICATION_PRIORITY_MIN = -2;
|
|
345
|
-
var ACTIVITY_TYPE_OTHER = 1;
|
|
346
|
-
var ACTIVITY_TYPE_AUTOMOTIVE_NAVIGATION = 2;
|
|
347
|
-
var ACTIVITY_TYPE_FITNESS = 3;
|
|
348
|
-
var ACTIVITY_TYPE_OTHER_NAVIGATION = 4;
|
|
349
|
-
var ACTIVITY_TYPE_AIRBORNE = 5;
|
|
350
|
-
var LOCATION_AUTHORIZATION_ALWAYS = "Always";
|
|
351
|
-
var LOCATION_AUTHORIZATION_WHEN_IN_USE = "WhenInUse";
|
|
352
|
-
var LOCATION_AUTHORIZATION_ANY = "Any";
|
|
353
|
-
var PERSIST_MODE_ALL = 2;
|
|
354
|
-
var PERSIST_MODE_LOCATION = 1;
|
|
355
|
-
var PERSIST_MODE_GEOFENCE = -1;
|
|
356
|
-
var PERSIST_MODE_NONE = 0;
|
|
357
|
-
var ACCURACY_AUTHORIZATION_FULL = 0;
|
|
358
|
-
var ACCURACY_AUTHORIZATION_REDUCED = 1;
|
|
310
|
+
var LOG_LEVEL_OFF = backgroundGeolocationTypes.LogLevel.Off;
|
|
311
|
+
var LOG_LEVEL_ERROR = backgroundGeolocationTypes.LogLevel.Error;
|
|
312
|
+
var LOG_LEVEL_WARNING = backgroundGeolocationTypes.LogLevel.Warning;
|
|
313
|
+
var LOG_LEVEL_INFO = backgroundGeolocationTypes.LogLevel.Info;
|
|
314
|
+
var LOG_LEVEL_DEBUG = backgroundGeolocationTypes.LogLevel.Debug;
|
|
315
|
+
var LOG_LEVEL_VERBOSE = backgroundGeolocationTypes.LogLevel.Verbose;
|
|
316
|
+
var DESIRED_ACCURACY_NAVIGATION = backgroundGeolocationTypes.DesiredAccuracy.Navigation;
|
|
317
|
+
var DESIRED_ACCURACY_HIGH = backgroundGeolocationTypes.DesiredAccuracy.High;
|
|
318
|
+
var DESIRED_ACCURACY_MEDIUM = backgroundGeolocationTypes.DesiredAccuracy.Medium;
|
|
319
|
+
var DESIRED_ACCURACY_LOW = backgroundGeolocationTypes.DesiredAccuracy.Low;
|
|
320
|
+
var DESIRED_ACCURACY_VERY_LOW = backgroundGeolocationTypes.DesiredAccuracy.VeryLow;
|
|
321
|
+
var DESIRED_ACCURACY_LOWEST = backgroundGeolocationTypes.DesiredAccuracy.Lowest;
|
|
322
|
+
var AUTHORIZATION_STATUS_NOT_DETERMINED = backgroundGeolocationTypes.AuthorizationStatus.NotDetermined;
|
|
323
|
+
var AUTHORIZATION_STATUS_RESTRICTED = backgroundGeolocationTypes.AuthorizationStatus.Restricted;
|
|
324
|
+
var AUTHORIZATION_STATUS_DENIED = backgroundGeolocationTypes.AuthorizationStatus.Denied;
|
|
325
|
+
var AUTHORIZATION_STATUS_ALWAYS = backgroundGeolocationTypes.AuthorizationStatus.Always;
|
|
326
|
+
var AUTHORIZATION_STATUS_WHEN_IN_USE = backgroundGeolocationTypes.AuthorizationStatus.WhenInUse;
|
|
327
|
+
var NOTIFICATION_PRIORITY_DEFAULT = backgroundGeolocationTypes.NotificationPriority.Default;
|
|
328
|
+
var NOTIFICATION_PRIORITY_HIGH = backgroundGeolocationTypes.NotificationPriority.High;
|
|
329
|
+
var NOTIFICATION_PRIORITY_LOW = backgroundGeolocationTypes.NotificationPriority.Low;
|
|
330
|
+
var NOTIFICATION_PRIORITY_MAX = backgroundGeolocationTypes.NotificationPriority.Max;
|
|
331
|
+
var NOTIFICATION_PRIORITY_MIN = backgroundGeolocationTypes.NotificationPriority.Min;
|
|
332
|
+
var ACTIVITY_TYPE_OTHER = backgroundGeolocationTypes.ActivityType.Other;
|
|
333
|
+
var ACTIVITY_TYPE_AUTOMOTIVE_NAVIGATION = backgroundGeolocationTypes.ActivityType.AutomotiveNavigation;
|
|
334
|
+
var ACTIVITY_TYPE_FITNESS = backgroundGeolocationTypes.ActivityType.Fitness;
|
|
335
|
+
var ACTIVITY_TYPE_OTHER_NAVIGATION = backgroundGeolocationTypes.ActivityType.OtherNavigation;
|
|
336
|
+
var ACTIVITY_TYPE_AIRBORNE = backgroundGeolocationTypes.ActivityType.Airborne;
|
|
337
|
+
var LOCATION_AUTHORIZATION_ALWAYS = backgroundGeolocationTypes.LocationRequest.Always;
|
|
338
|
+
var LOCATION_AUTHORIZATION_WHEN_IN_USE = backgroundGeolocationTypes.LocationRequest.WhenInUse;
|
|
339
|
+
var LOCATION_AUTHORIZATION_ANY = backgroundGeolocationTypes.LocationRequest.Any;
|
|
340
|
+
var PERSIST_MODE_ALL = backgroundGeolocationTypes.PersistMode.All;
|
|
341
|
+
var PERSIST_MODE_LOCATION = backgroundGeolocationTypes.PersistMode.Location;
|
|
342
|
+
var PERSIST_MODE_GEOFENCE = backgroundGeolocationTypes.PersistMode.Geofence;
|
|
343
|
+
var PERSIST_MODE_NONE = backgroundGeolocationTypes.PersistMode.None;
|
|
344
|
+
var ACCURACY_AUTHORIZATION_FULL = backgroundGeolocationTypes.AccuracyAuthorization.Full;
|
|
345
|
+
var ACCURACY_AUTHORIZATION_REDUCED = backgroundGeolocationTypes.AccuracyAuthorization.Reduced;
|
|
359
346
|
/// BackgroundGeolocation JS API
|
|
360
347
|
var BackgroundGeolocation = /** @class */ (function () {
|
|
361
348
|
function BackgroundGeolocation() {
|
|
362
349
|
}
|
|
350
|
+
Object.defineProperty(BackgroundGeolocation, "LogLevel", {
|
|
351
|
+
get: function () { return backgroundGeolocationTypes.LogLevel; },
|
|
352
|
+
enumerable: false,
|
|
353
|
+
configurable: true
|
|
354
|
+
});
|
|
355
|
+
Object.defineProperty(BackgroundGeolocation, "DesiredAccuracy", {
|
|
356
|
+
get: function () { return backgroundGeolocationTypes.DesiredAccuracy; },
|
|
357
|
+
enumerable: false,
|
|
358
|
+
configurable: true
|
|
359
|
+
});
|
|
360
|
+
Object.defineProperty(BackgroundGeolocation, "PersistMode", {
|
|
361
|
+
get: function () { return backgroundGeolocationTypes.PersistMode; },
|
|
362
|
+
enumerable: false,
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
365
|
+
Object.defineProperty(BackgroundGeolocation, "AuthorizationStatus", {
|
|
366
|
+
get: function () { return backgroundGeolocationTypes.AuthorizationStatus; },
|
|
367
|
+
enumerable: false,
|
|
368
|
+
configurable: true
|
|
369
|
+
});
|
|
370
|
+
Object.defineProperty(BackgroundGeolocation, "AccuracyAuthorization", {
|
|
371
|
+
get: function () { return backgroundGeolocationTypes.AccuracyAuthorization; },
|
|
372
|
+
enumerable: false,
|
|
373
|
+
configurable: true
|
|
374
|
+
});
|
|
375
|
+
Object.defineProperty(BackgroundGeolocation, "AuthorizationStrategy", {
|
|
376
|
+
get: function () { return backgroundGeolocationTypes.AuthorizationStrategy; },
|
|
377
|
+
enumerable: false,
|
|
378
|
+
configurable: true
|
|
379
|
+
});
|
|
380
|
+
Object.defineProperty(BackgroundGeolocation, "LocationFilterPolicy", {
|
|
381
|
+
get: function () { return backgroundGeolocationTypes.LocationFilterPolicy; },
|
|
382
|
+
enumerable: false,
|
|
383
|
+
configurable: true
|
|
384
|
+
});
|
|
385
|
+
Object.defineProperty(BackgroundGeolocation, "KalmanProfile", {
|
|
386
|
+
get: function () { return backgroundGeolocationTypes.KalmanProfile; },
|
|
387
|
+
enumerable: false,
|
|
388
|
+
configurable: true
|
|
389
|
+
});
|
|
390
|
+
Object.defineProperty(BackgroundGeolocation, "HttpMethod", {
|
|
391
|
+
get: function () { return backgroundGeolocationTypes.HttpMethod; },
|
|
392
|
+
enumerable: false,
|
|
393
|
+
configurable: true
|
|
394
|
+
});
|
|
395
|
+
Object.defineProperty(BackgroundGeolocation, "TriggerActivity", {
|
|
396
|
+
get: function () { return backgroundGeolocationTypes.TriggerActivity; },
|
|
397
|
+
enumerable: false,
|
|
398
|
+
configurable: true
|
|
399
|
+
});
|
|
363
400
|
Object.defineProperty(BackgroundGeolocation, "EVENT_BOOT", {
|
|
364
401
|
/// Events
|
|
365
|
-
get: function () { return
|
|
402
|
+
get: function () { return backgroundGeolocationTypes.Event.Boot; },
|
|
366
403
|
enumerable: false,
|
|
367
404
|
configurable: true
|
|
368
405
|
});
|
|
369
406
|
Object.defineProperty(BackgroundGeolocation, "EVENT_TERMINATE", {
|
|
370
|
-
get: function () { return
|
|
407
|
+
get: function () { return backgroundGeolocationTypes.Event.Terminate; },
|
|
371
408
|
enumerable: false,
|
|
372
409
|
configurable: true
|
|
373
410
|
});
|
|
374
411
|
Object.defineProperty(BackgroundGeolocation, "EVENT_LOCATION", {
|
|
375
|
-
get: function () { return
|
|
412
|
+
get: function () { return backgroundGeolocationTypes.Event.Location; },
|
|
376
413
|
enumerable: false,
|
|
377
414
|
configurable: true
|
|
378
415
|
});
|
|
379
416
|
Object.defineProperty(BackgroundGeolocation, "EVENT_MOTIONCHANGE", {
|
|
380
|
-
get: function () { return
|
|
417
|
+
get: function () { return backgroundGeolocationTypes.Event.MotionChange; },
|
|
381
418
|
enumerable: false,
|
|
382
419
|
configurable: true
|
|
383
420
|
});
|
|
384
421
|
Object.defineProperty(BackgroundGeolocation, "EVENT_HTTP", {
|
|
385
|
-
get: function () { return
|
|
422
|
+
get: function () { return backgroundGeolocationTypes.Event.Http; },
|
|
386
423
|
enumerable: false,
|
|
387
424
|
configurable: true
|
|
388
425
|
});
|
|
389
426
|
Object.defineProperty(BackgroundGeolocation, "EVENT_HEARTBEAT", {
|
|
390
|
-
get: function () { return
|
|
427
|
+
get: function () { return backgroundGeolocationTypes.Event.Heartbeat; },
|
|
391
428
|
enumerable: false,
|
|
392
429
|
configurable: true
|
|
393
430
|
});
|
|
394
431
|
Object.defineProperty(BackgroundGeolocation, "EVENT_PROVIDERCHANGE", {
|
|
395
|
-
get: function () { return
|
|
432
|
+
get: function () { return backgroundGeolocationTypes.Event.ProviderChange; },
|
|
396
433
|
enumerable: false,
|
|
397
434
|
configurable: true
|
|
398
435
|
});
|
|
399
436
|
Object.defineProperty(BackgroundGeolocation, "EVENT_ACTIVITYCHANGE", {
|
|
400
|
-
get: function () { return
|
|
437
|
+
get: function () { return backgroundGeolocationTypes.Event.ActivityChange; },
|
|
401
438
|
enumerable: false,
|
|
402
439
|
configurable: true
|
|
403
440
|
});
|
|
404
441
|
Object.defineProperty(BackgroundGeolocation, "EVENT_GEOFENCE", {
|
|
405
|
-
get: function () { return
|
|
442
|
+
get: function () { return backgroundGeolocationTypes.Event.Geofence; },
|
|
406
443
|
enumerable: false,
|
|
407
444
|
configurable: true
|
|
408
445
|
});
|
|
409
446
|
Object.defineProperty(BackgroundGeolocation, "EVENT_GEOFENCESCHANGE", {
|
|
410
|
-
get: function () { return
|
|
447
|
+
get: function () { return backgroundGeolocationTypes.Event.GeofencesChange; },
|
|
411
448
|
enumerable: false,
|
|
412
449
|
configurable: true
|
|
413
450
|
});
|
|
414
451
|
Object.defineProperty(BackgroundGeolocation, "EVENT_ENABLEDCHANGE", {
|
|
415
|
-
get: function () { return
|
|
452
|
+
get: function () { return backgroundGeolocationTypes.Event.EnabledChange; },
|
|
416
453
|
enumerable: false,
|
|
417
454
|
configurable: true
|
|
418
455
|
});
|
|
419
456
|
Object.defineProperty(BackgroundGeolocation, "EVENT_CONNECTIVITYCHANGE", {
|
|
420
|
-
get: function () { return
|
|
457
|
+
get: function () { return backgroundGeolocationTypes.Event.ConnectivityChange; },
|
|
421
458
|
enumerable: false,
|
|
422
459
|
configurable: true
|
|
423
460
|
});
|
|
424
461
|
Object.defineProperty(BackgroundGeolocation, "EVENT_SCHEDULE", {
|
|
425
|
-
get: function () { return
|
|
462
|
+
get: function () { return backgroundGeolocationTypes.Event.Schedule; },
|
|
426
463
|
enumerable: false,
|
|
427
464
|
configurable: true
|
|
428
465
|
});
|
|
429
466
|
Object.defineProperty(BackgroundGeolocation, "EVENT_POWERSAVECHANGE", {
|
|
430
|
-
get: function () { return
|
|
467
|
+
get: function () { return backgroundGeolocationTypes.Event.PowerSaveChange; },
|
|
431
468
|
enumerable: false,
|
|
432
469
|
configurable: true
|
|
433
470
|
});
|
|
434
471
|
Object.defineProperty(BackgroundGeolocation, "EVENT_NOTIFICATIONACTION", {
|
|
435
|
-
get: function () { return
|
|
472
|
+
get: function () { return "notificationaction"; } // <-- TODO : Add to background-geolocation-types
|
|
473
|
+
,
|
|
436
474
|
enumerable: false,
|
|
437
475
|
configurable: true
|
|
438
476
|
});
|
|
439
477
|
Object.defineProperty(BackgroundGeolocation, "EVENT_AUTHORIZATION", {
|
|
440
|
-
get: function () { return
|
|
478
|
+
get: function () { return backgroundGeolocationTypes.Event.Authorization; },
|
|
441
479
|
enumerable: false,
|
|
442
480
|
configurable: true
|
|
443
481
|
});
|
|
@@ -632,10 +670,10 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
632
670
|
configurable: true
|
|
633
671
|
});
|
|
634
672
|
BackgroundGeolocation.ready = function (config) {
|
|
635
|
-
return NativeModule.ready({ options:
|
|
673
|
+
return NativeModule.ready({ options: config });
|
|
636
674
|
};
|
|
637
675
|
BackgroundGeolocation.reset = function (config) {
|
|
638
|
-
return NativeModule.reset({ options:
|
|
676
|
+
return NativeModule.reset({ options: config });
|
|
639
677
|
};
|
|
640
678
|
BackgroundGeolocation.start = function () {
|
|
641
679
|
return NativeModule.start();
|
|
@@ -653,7 +691,7 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
653
691
|
return NativeModule.startGeofences();
|
|
654
692
|
};
|
|
655
693
|
BackgroundGeolocation.setConfig = function (config) {
|
|
656
|
-
return NativeModule.setConfig({ options:
|
|
694
|
+
return NativeModule.setConfig({ options: config });
|
|
657
695
|
};
|
|
658
696
|
BackgroundGeolocation.getState = function () {
|
|
659
697
|
return NativeModule.getState();
|
|
@@ -677,48 +715,63 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
677
715
|
});
|
|
678
716
|
});
|
|
679
717
|
};
|
|
680
|
-
BackgroundGeolocation.watchPosition = function (onLocation, onError
|
|
681
|
-
var _this = this;
|
|
718
|
+
BackgroundGeolocation.watchPosition = function (options, onLocation, onError) {
|
|
682
719
|
options = options || {};
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
697
|
-
else {
|
|
698
|
-
onLocation(response);
|
|
699
|
-
}
|
|
700
|
-
};
|
|
701
|
-
return [4 /*yield*/, NativeModule.addListener("watchposition", handler)];
|
|
702
|
-
case 1:
|
|
703
|
-
listener = _a.sent();
|
|
704
|
-
NativeModule.watchPosition({ options: options }).then(function () {
|
|
705
|
-
WATCH_POSITION_SUBSCRIPTIONS.push(listener);
|
|
706
|
-
resolve();
|
|
707
|
-
}).catch(function (error) {
|
|
708
|
-
listener.remove();
|
|
709
|
-
reject(error.message);
|
|
710
|
-
});
|
|
711
|
-
return [2 /*return*/];
|
|
720
|
+
var isRemoved = false;
|
|
721
|
+
var nativeWatchId = null;
|
|
722
|
+
var subscriptionProxy = {
|
|
723
|
+
remove: function () {
|
|
724
|
+
isRemoved = true;
|
|
725
|
+
if (nativeWatchId !== null) {
|
|
726
|
+
var listener = WATCH_POSITION_SUBSCRIPTIONS.get(nativeWatchId);
|
|
727
|
+
if (listener) {
|
|
728
|
+
listener.remove();
|
|
729
|
+
WATCH_POSITION_SUBSCRIPTIONS.delete(nativeWatchId);
|
|
730
|
+
}
|
|
731
|
+
NativeModule.stopWatchPosition({ watchId: nativeWatchId });
|
|
732
|
+
nativeWatchId = null;
|
|
712
733
|
}
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
var handler = function (response) {
|
|
737
|
+
if (response.hasOwnProperty("error") && (response.error != null)) {
|
|
738
|
+
if (typeof (onError) === 'function') {
|
|
739
|
+
onError(response.error.code);
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
console.warn('[BackgroundGeolocation watchPosition] DEFAULT ERROR HANDLER. Provide an onError callback to watchPosition to receive this message: ', response.error);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
onLocation(response);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
NativeModule.addListener("watchposition", handler).then(function (listener) {
|
|
750
|
+
NativeModule.watchPosition({ options: options }).then(function (result) {
|
|
751
|
+
nativeWatchId = result.watchId;
|
|
752
|
+
if (isRemoved) {
|
|
753
|
+
// remove() was called before the native async call resolved — honour it now.
|
|
754
|
+
listener.remove();
|
|
755
|
+
NativeModule.stopWatchPosition({ watchId: nativeWatchId });
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
WATCH_POSITION_SUBSCRIPTIONS.set(nativeWatchId, listener);
|
|
759
|
+
}
|
|
760
|
+
}).catch(function () {
|
|
761
|
+
listener.remove();
|
|
713
762
|
});
|
|
714
|
-
});
|
|
763
|
+
});
|
|
764
|
+
return subscriptionProxy;
|
|
715
765
|
};
|
|
716
|
-
BackgroundGeolocation.stopWatchPosition = function () {
|
|
717
|
-
|
|
718
|
-
var
|
|
719
|
-
|
|
766
|
+
BackgroundGeolocation.stopWatchPosition = function (watchId) {
|
|
767
|
+
if (watchId !== undefined) {
|
|
768
|
+
var listener = WATCH_POSITION_SUBSCRIPTIONS.get(watchId);
|
|
769
|
+
if (listener) {
|
|
770
|
+
listener.remove();
|
|
771
|
+
WATCH_POSITION_SUBSCRIPTIONS.delete(watchId);
|
|
772
|
+
}
|
|
773
|
+
NativeModule.stopWatchPosition({ watchId: watchId });
|
|
720
774
|
}
|
|
721
|
-
return NativeModule.stopWatchPosition();
|
|
722
775
|
};
|
|
723
776
|
BackgroundGeolocation.requestPermission = function () {
|
|
724
777
|
return new Promise(function (resolve, reject) {
|
|
@@ -953,55 +1006,52 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
953
1006
|
};
|
|
954
1007
|
/// Event Handling
|
|
955
1008
|
///
|
|
956
|
-
BackgroundGeolocation.onLocation = function (
|
|
957
|
-
return BackgroundGeolocation.addListener(
|
|
1009
|
+
BackgroundGeolocation.onLocation = function (cb, onError) {
|
|
1010
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.Location, cb, onError);
|
|
958
1011
|
};
|
|
959
|
-
BackgroundGeolocation.onMotionChange = function (
|
|
960
|
-
return BackgroundGeolocation.addListener(
|
|
1012
|
+
BackgroundGeolocation.onMotionChange = function (cb) {
|
|
1013
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.MotionChange, cb);
|
|
961
1014
|
};
|
|
962
|
-
BackgroundGeolocation.onHttp = function (
|
|
963
|
-
return BackgroundGeolocation.addListener(
|
|
1015
|
+
BackgroundGeolocation.onHttp = function (cb) {
|
|
1016
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.Http, cb);
|
|
964
1017
|
};
|
|
965
|
-
BackgroundGeolocation.onHeartbeat = function (
|
|
966
|
-
return BackgroundGeolocation.addListener(
|
|
1018
|
+
BackgroundGeolocation.onHeartbeat = function (cb) {
|
|
1019
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.Heartbeat, cb);
|
|
967
1020
|
};
|
|
968
|
-
BackgroundGeolocation.onProviderChange = function (
|
|
969
|
-
return BackgroundGeolocation.addListener(
|
|
1021
|
+
BackgroundGeolocation.onProviderChange = function (cb) {
|
|
1022
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.ProviderChange, cb);
|
|
970
1023
|
};
|
|
971
|
-
BackgroundGeolocation.onActivityChange = function (
|
|
972
|
-
return BackgroundGeolocation.addListener(
|
|
1024
|
+
BackgroundGeolocation.onActivityChange = function (cb) {
|
|
1025
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.ActivityChange, cb);
|
|
973
1026
|
};
|
|
974
|
-
BackgroundGeolocation.onGeofence = function (
|
|
975
|
-
return BackgroundGeolocation.addListener(
|
|
1027
|
+
BackgroundGeolocation.onGeofence = function (cb) {
|
|
1028
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.Geofence, cb);
|
|
976
1029
|
};
|
|
977
|
-
BackgroundGeolocation.onGeofencesChange = function (
|
|
978
|
-
return BackgroundGeolocation.addListener(
|
|
1030
|
+
BackgroundGeolocation.onGeofencesChange = function (cb) {
|
|
1031
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.GeofencesChange, cb);
|
|
979
1032
|
};
|
|
980
|
-
BackgroundGeolocation.onSchedule = function (
|
|
981
|
-
return BackgroundGeolocation.addListener(
|
|
1033
|
+
BackgroundGeolocation.onSchedule = function (cb) {
|
|
1034
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.Schedule, cb);
|
|
982
1035
|
};
|
|
983
|
-
BackgroundGeolocation.onEnabledChange = function (
|
|
984
|
-
return BackgroundGeolocation.addListener(
|
|
1036
|
+
BackgroundGeolocation.onEnabledChange = function (cb) {
|
|
1037
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.EnabledChange, cb);
|
|
985
1038
|
};
|
|
986
|
-
BackgroundGeolocation.onConnectivityChange = function (
|
|
987
|
-
return BackgroundGeolocation.addListener(
|
|
1039
|
+
BackgroundGeolocation.onConnectivityChange = function (cb) {
|
|
1040
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.ConnectivityChange, cb);
|
|
988
1041
|
};
|
|
989
|
-
BackgroundGeolocation.onPowerSaveChange = function (
|
|
990
|
-
return BackgroundGeolocation.addListener(
|
|
1042
|
+
BackgroundGeolocation.onPowerSaveChange = function (cb) {
|
|
1043
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.PowerSaveChange, cb);
|
|
991
1044
|
};
|
|
992
|
-
BackgroundGeolocation.onNotificationAction = function (
|
|
993
|
-
return BackgroundGeolocation.addListener(
|
|
1045
|
+
BackgroundGeolocation.onNotificationAction = function (cb) {
|
|
1046
|
+
return BackgroundGeolocation.addListener("notificationaction", cb);
|
|
994
1047
|
};
|
|
995
|
-
BackgroundGeolocation.onAuthorization = function (
|
|
996
|
-
return BackgroundGeolocation.addListener(
|
|
1048
|
+
BackgroundGeolocation.onAuthorization = function (cb) {
|
|
1049
|
+
return BackgroundGeolocation.addListener(backgroundGeolocationTypes.Event.Authorization, cb);
|
|
997
1050
|
};
|
|
998
1051
|
///
|
|
999
1052
|
/// Listen to a plugin event
|
|
1000
1053
|
///
|
|
1001
1054
|
BackgroundGeolocation.addListener = function (event, success, failure) {
|
|
1002
|
-
if (!Events[event.toUpperCase()]) {
|
|
1003
|
-
throw (TAG + "#addListener - Unknown event '" + event + "'");
|
|
1004
|
-
}
|
|
1005
1055
|
var handler = function (response) {
|
|
1006
1056
|
if (response.hasOwnProperty("value")) {
|
|
1007
1057
|
response = response.value;
|