@transistorsoft/capacitor-background-geolocation 8.0.0 → 9.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/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 +11 -12
- 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/index.js
CHANGED
|
@@ -1,40 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
37
2
|
import { registerPlugin } from '@capacitor/core';
|
|
3
|
+
import { LogLevel, DesiredAccuracy, PersistMode, AuthorizationStatus, AccuracyAuthorization, LocationRequest, AuthorizationStrategy, LocationFilterPolicy, KalmanProfile, NotificationPriority, HttpMethod, TriggerActivity, ActivityType, Event } from '@transistorsoft/background-geolocation-types';
|
|
38
4
|
var NativeModule = registerPlugin('BackgroundGeolocation');
|
|
39
5
|
/**
|
|
40
6
|
* Logger
|
|
@@ -191,7 +157,10 @@ var TransistorAuthorizationToken = /** @class */ (function () {
|
|
|
191
157
|
return config;
|
|
192
158
|
var token = config.transistorAuthorizationToken;
|
|
193
159
|
delete config.transistorAuthorizationToken;
|
|
194
|
-
config.
|
|
160
|
+
if (!config.http) {
|
|
161
|
+
config.http = {};
|
|
162
|
+
}
|
|
163
|
+
config.http.url = token.url + LOCATIONS_PATH;
|
|
195
164
|
config.authorization = {
|
|
196
165
|
strategy: 'JWT',
|
|
197
166
|
accessToken: token.accessToken,
|
|
@@ -210,8 +179,10 @@ var TransistorAuthorizationToken = /** @class */ (function () {
|
|
|
210
179
|
var IGNORE_BATTERY_OPTIMIZATIONS = "IGNORE_BATTERY_OPTIMIZATIONS";
|
|
211
180
|
var POWER_MANAGER = "POWER_MANAGER";
|
|
212
181
|
var resolveSettingsRequest = function (resolve, request) {
|
|
213
|
-
|
|
214
|
-
|
|
182
|
+
// lastSeenAt arrives from the native bridge as a unix timestamp (number); convert to Date.
|
|
183
|
+
var lastSeenAt = request.lastSeenAt;
|
|
184
|
+
if (lastSeenAt > 0) {
|
|
185
|
+
request.lastSeenAt = new Date(lastSeenAt);
|
|
215
186
|
}
|
|
216
187
|
resolve(request);
|
|
217
188
|
};
|
|
@@ -259,12 +230,11 @@ var DeviceSettings = /** @class */ (function () {
|
|
|
259
230
|
};
|
|
260
231
|
return DeviceSettings;
|
|
261
232
|
}());
|
|
262
|
-
import { Events } from "./Events";
|
|
263
233
|
var TAG = "TSLocationManager";
|
|
264
234
|
/// Container for event-subscriptions.
|
|
265
235
|
var EVENT_SUBSCRIPTIONS = [];
|
|
266
|
-
/// Container for
|
|
267
|
-
var WATCH_POSITION_SUBSCRIPTIONS =
|
|
236
|
+
/// Container for watchPosition subscriptions, keyed by watchId.
|
|
237
|
+
var WATCH_POSITION_SUBSCRIPTIONS = new Map();
|
|
268
238
|
/// Event handler Subscription
|
|
269
239
|
///
|
|
270
240
|
var Subscription = /** @class */ (function () {
|
|
@@ -275,148 +245,175 @@ var Subscription = /** @class */ (function () {
|
|
|
275
245
|
}
|
|
276
246
|
return Subscription;
|
|
277
247
|
}());
|
|
278
|
-
|
|
279
|
-
var
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
var
|
|
303
|
-
var
|
|
304
|
-
var
|
|
305
|
-
var
|
|
306
|
-
var
|
|
307
|
-
var
|
|
308
|
-
var
|
|
309
|
-
var
|
|
310
|
-
var
|
|
311
|
-
var
|
|
312
|
-
var
|
|
313
|
-
var
|
|
314
|
-
var AUTHORIZATION_STATUS_NOT_DETERMINED = 0;
|
|
315
|
-
var AUTHORIZATION_STATUS_RESTRICTED = 1;
|
|
316
|
-
var AUTHORIZATION_STATUS_DENIED = 2;
|
|
317
|
-
var AUTHORIZATION_STATUS_ALWAYS = 3;
|
|
318
|
-
var AUTHORIZATION_STATUS_WHEN_IN_USE = 4;
|
|
319
|
-
var NOTIFICATION_PRIORITY_DEFAULT = 0;
|
|
320
|
-
var NOTIFICATION_PRIORITY_HIGH = 1;
|
|
321
|
-
var NOTIFICATION_PRIORITY_LOW = -1;
|
|
322
|
-
var NOTIFICATION_PRIORITY_MAX = 2;
|
|
323
|
-
var NOTIFICATION_PRIORITY_MIN = -2;
|
|
324
|
-
var ACTIVITY_TYPE_OTHER = 1;
|
|
325
|
-
var ACTIVITY_TYPE_AUTOMOTIVE_NAVIGATION = 2;
|
|
326
|
-
var ACTIVITY_TYPE_FITNESS = 3;
|
|
327
|
-
var ACTIVITY_TYPE_OTHER_NAVIGATION = 4;
|
|
328
|
-
var ACTIVITY_TYPE_AIRBORNE = 5;
|
|
329
|
-
var LOCATION_AUTHORIZATION_ALWAYS = "Always";
|
|
330
|
-
var LOCATION_AUTHORIZATION_WHEN_IN_USE = "WhenInUse";
|
|
331
|
-
var LOCATION_AUTHORIZATION_ANY = "Any";
|
|
332
|
-
var PERSIST_MODE_ALL = 2;
|
|
333
|
-
var PERSIST_MODE_LOCATION = 1;
|
|
334
|
-
var PERSIST_MODE_GEOFENCE = -1;
|
|
335
|
-
var PERSIST_MODE_NONE = 0;
|
|
336
|
-
var ACCURACY_AUTHORIZATION_FULL = 0;
|
|
337
|
-
var ACCURACY_AUTHORIZATION_REDUCED = 1;
|
|
248
|
+
var LOG_LEVEL_OFF = LogLevel.Off;
|
|
249
|
+
var LOG_LEVEL_ERROR = LogLevel.Error;
|
|
250
|
+
var LOG_LEVEL_WARNING = LogLevel.Warning;
|
|
251
|
+
var LOG_LEVEL_INFO = LogLevel.Info;
|
|
252
|
+
var LOG_LEVEL_DEBUG = LogLevel.Debug;
|
|
253
|
+
var LOG_LEVEL_VERBOSE = LogLevel.Verbose;
|
|
254
|
+
var DESIRED_ACCURACY_NAVIGATION = DesiredAccuracy.Navigation;
|
|
255
|
+
var DESIRED_ACCURACY_HIGH = DesiredAccuracy.High;
|
|
256
|
+
var DESIRED_ACCURACY_MEDIUM = DesiredAccuracy.Medium;
|
|
257
|
+
var DESIRED_ACCURACY_LOW = DesiredAccuracy.Low;
|
|
258
|
+
var DESIRED_ACCURACY_VERY_LOW = DesiredAccuracy.VeryLow;
|
|
259
|
+
var DESIRED_ACCURACY_LOWEST = DesiredAccuracy.Lowest;
|
|
260
|
+
var AUTHORIZATION_STATUS_NOT_DETERMINED = AuthorizationStatus.NotDetermined;
|
|
261
|
+
var AUTHORIZATION_STATUS_RESTRICTED = AuthorizationStatus.Restricted;
|
|
262
|
+
var AUTHORIZATION_STATUS_DENIED = AuthorizationStatus.Denied;
|
|
263
|
+
var AUTHORIZATION_STATUS_ALWAYS = AuthorizationStatus.Always;
|
|
264
|
+
var AUTHORIZATION_STATUS_WHEN_IN_USE = AuthorizationStatus.WhenInUse;
|
|
265
|
+
var NOTIFICATION_PRIORITY_DEFAULT = NotificationPriority.Default;
|
|
266
|
+
var NOTIFICATION_PRIORITY_HIGH = NotificationPriority.High;
|
|
267
|
+
var NOTIFICATION_PRIORITY_LOW = NotificationPriority.Low;
|
|
268
|
+
var NOTIFICATION_PRIORITY_MAX = NotificationPriority.Max;
|
|
269
|
+
var NOTIFICATION_PRIORITY_MIN = NotificationPriority.Min;
|
|
270
|
+
var ACTIVITY_TYPE_OTHER = ActivityType.Other;
|
|
271
|
+
var ACTIVITY_TYPE_AUTOMOTIVE_NAVIGATION = ActivityType.AutomotiveNavigation;
|
|
272
|
+
var ACTIVITY_TYPE_FITNESS = ActivityType.Fitness;
|
|
273
|
+
var ACTIVITY_TYPE_OTHER_NAVIGATION = ActivityType.OtherNavigation;
|
|
274
|
+
var ACTIVITY_TYPE_AIRBORNE = ActivityType.Airborne;
|
|
275
|
+
var LOCATION_AUTHORIZATION_ALWAYS = LocationRequest.Always;
|
|
276
|
+
var LOCATION_AUTHORIZATION_WHEN_IN_USE = LocationRequest.WhenInUse;
|
|
277
|
+
var LOCATION_AUTHORIZATION_ANY = LocationRequest.Any;
|
|
278
|
+
var PERSIST_MODE_ALL = PersistMode.All;
|
|
279
|
+
var PERSIST_MODE_LOCATION = PersistMode.Location;
|
|
280
|
+
var PERSIST_MODE_GEOFENCE = PersistMode.Geofence;
|
|
281
|
+
var PERSIST_MODE_NONE = PersistMode.None;
|
|
282
|
+
var ACCURACY_AUTHORIZATION_FULL = AccuracyAuthorization.Full;
|
|
283
|
+
var ACCURACY_AUTHORIZATION_REDUCED = AccuracyAuthorization.Reduced;
|
|
338
284
|
/// BackgroundGeolocation JS API
|
|
339
285
|
var BackgroundGeolocation = /** @class */ (function () {
|
|
340
286
|
function BackgroundGeolocation() {
|
|
341
287
|
}
|
|
288
|
+
Object.defineProperty(BackgroundGeolocation, "LogLevel", {
|
|
289
|
+
get: function () { return LogLevel; },
|
|
290
|
+
enumerable: false,
|
|
291
|
+
configurable: true
|
|
292
|
+
});
|
|
293
|
+
Object.defineProperty(BackgroundGeolocation, "DesiredAccuracy", {
|
|
294
|
+
get: function () { return DesiredAccuracy; },
|
|
295
|
+
enumerable: false,
|
|
296
|
+
configurable: true
|
|
297
|
+
});
|
|
298
|
+
Object.defineProperty(BackgroundGeolocation, "PersistMode", {
|
|
299
|
+
get: function () { return PersistMode; },
|
|
300
|
+
enumerable: false,
|
|
301
|
+
configurable: true
|
|
302
|
+
});
|
|
303
|
+
Object.defineProperty(BackgroundGeolocation, "AuthorizationStatus", {
|
|
304
|
+
get: function () { return AuthorizationStatus; },
|
|
305
|
+
enumerable: false,
|
|
306
|
+
configurable: true
|
|
307
|
+
});
|
|
308
|
+
Object.defineProperty(BackgroundGeolocation, "AccuracyAuthorization", {
|
|
309
|
+
get: function () { return AccuracyAuthorization; },
|
|
310
|
+
enumerable: false,
|
|
311
|
+
configurable: true
|
|
312
|
+
});
|
|
313
|
+
Object.defineProperty(BackgroundGeolocation, "AuthorizationStrategy", {
|
|
314
|
+
get: function () { return AuthorizationStrategy; },
|
|
315
|
+
enumerable: false,
|
|
316
|
+
configurable: true
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperty(BackgroundGeolocation, "LocationFilterPolicy", {
|
|
319
|
+
get: function () { return LocationFilterPolicy; },
|
|
320
|
+
enumerable: false,
|
|
321
|
+
configurable: true
|
|
322
|
+
});
|
|
323
|
+
Object.defineProperty(BackgroundGeolocation, "KalmanProfile", {
|
|
324
|
+
get: function () { return KalmanProfile; },
|
|
325
|
+
enumerable: false,
|
|
326
|
+
configurable: true
|
|
327
|
+
});
|
|
328
|
+
Object.defineProperty(BackgroundGeolocation, "HttpMethod", {
|
|
329
|
+
get: function () { return HttpMethod; },
|
|
330
|
+
enumerable: false,
|
|
331
|
+
configurable: true
|
|
332
|
+
});
|
|
333
|
+
Object.defineProperty(BackgroundGeolocation, "TriggerActivity", {
|
|
334
|
+
get: function () { return TriggerActivity; },
|
|
335
|
+
enumerable: false,
|
|
336
|
+
configurable: true
|
|
337
|
+
});
|
|
342
338
|
Object.defineProperty(BackgroundGeolocation, "EVENT_BOOT", {
|
|
343
339
|
/// Events
|
|
344
|
-
get: function () { return
|
|
340
|
+
get: function () { return Event.Boot; },
|
|
345
341
|
enumerable: false,
|
|
346
342
|
configurable: true
|
|
347
343
|
});
|
|
348
344
|
Object.defineProperty(BackgroundGeolocation, "EVENT_TERMINATE", {
|
|
349
|
-
get: function () { return
|
|
345
|
+
get: function () { return Event.Terminate; },
|
|
350
346
|
enumerable: false,
|
|
351
347
|
configurable: true
|
|
352
348
|
});
|
|
353
349
|
Object.defineProperty(BackgroundGeolocation, "EVENT_LOCATION", {
|
|
354
|
-
get: function () { return
|
|
350
|
+
get: function () { return Event.Location; },
|
|
355
351
|
enumerable: false,
|
|
356
352
|
configurable: true
|
|
357
353
|
});
|
|
358
354
|
Object.defineProperty(BackgroundGeolocation, "EVENT_MOTIONCHANGE", {
|
|
359
|
-
get: function () { return
|
|
355
|
+
get: function () { return Event.MotionChange; },
|
|
360
356
|
enumerable: false,
|
|
361
357
|
configurable: true
|
|
362
358
|
});
|
|
363
359
|
Object.defineProperty(BackgroundGeolocation, "EVENT_HTTP", {
|
|
364
|
-
get: function () { return
|
|
360
|
+
get: function () { return Event.Http; },
|
|
365
361
|
enumerable: false,
|
|
366
362
|
configurable: true
|
|
367
363
|
});
|
|
368
364
|
Object.defineProperty(BackgroundGeolocation, "EVENT_HEARTBEAT", {
|
|
369
|
-
get: function () { return
|
|
365
|
+
get: function () { return Event.Heartbeat; },
|
|
370
366
|
enumerable: false,
|
|
371
367
|
configurable: true
|
|
372
368
|
});
|
|
373
369
|
Object.defineProperty(BackgroundGeolocation, "EVENT_PROVIDERCHANGE", {
|
|
374
|
-
get: function () { return
|
|
370
|
+
get: function () { return Event.ProviderChange; },
|
|
375
371
|
enumerable: false,
|
|
376
372
|
configurable: true
|
|
377
373
|
});
|
|
378
374
|
Object.defineProperty(BackgroundGeolocation, "EVENT_ACTIVITYCHANGE", {
|
|
379
|
-
get: function () { return
|
|
375
|
+
get: function () { return Event.ActivityChange; },
|
|
380
376
|
enumerable: false,
|
|
381
377
|
configurable: true
|
|
382
378
|
});
|
|
383
379
|
Object.defineProperty(BackgroundGeolocation, "EVENT_GEOFENCE", {
|
|
384
|
-
get: function () { return
|
|
380
|
+
get: function () { return Event.Geofence; },
|
|
385
381
|
enumerable: false,
|
|
386
382
|
configurable: true
|
|
387
383
|
});
|
|
388
384
|
Object.defineProperty(BackgroundGeolocation, "EVENT_GEOFENCESCHANGE", {
|
|
389
|
-
get: function () { return
|
|
385
|
+
get: function () { return Event.GeofencesChange; },
|
|
390
386
|
enumerable: false,
|
|
391
387
|
configurable: true
|
|
392
388
|
});
|
|
393
389
|
Object.defineProperty(BackgroundGeolocation, "EVENT_ENABLEDCHANGE", {
|
|
394
|
-
get: function () { return
|
|
390
|
+
get: function () { return Event.EnabledChange; },
|
|
395
391
|
enumerable: false,
|
|
396
392
|
configurable: true
|
|
397
393
|
});
|
|
398
394
|
Object.defineProperty(BackgroundGeolocation, "EVENT_CONNECTIVITYCHANGE", {
|
|
399
|
-
get: function () { return
|
|
395
|
+
get: function () { return Event.ConnectivityChange; },
|
|
400
396
|
enumerable: false,
|
|
401
397
|
configurable: true
|
|
402
398
|
});
|
|
403
399
|
Object.defineProperty(BackgroundGeolocation, "EVENT_SCHEDULE", {
|
|
404
|
-
get: function () { return
|
|
400
|
+
get: function () { return Event.Schedule; },
|
|
405
401
|
enumerable: false,
|
|
406
402
|
configurable: true
|
|
407
403
|
});
|
|
408
404
|
Object.defineProperty(BackgroundGeolocation, "EVENT_POWERSAVECHANGE", {
|
|
409
|
-
get: function () { return
|
|
405
|
+
get: function () { return Event.PowerSaveChange; },
|
|
410
406
|
enumerable: false,
|
|
411
407
|
configurable: true
|
|
412
408
|
});
|
|
413
409
|
Object.defineProperty(BackgroundGeolocation, "EVENT_NOTIFICATIONACTION", {
|
|
414
|
-
get: function () { return
|
|
410
|
+
get: function () { return "notificationaction"; } // <-- TODO : Add to background-geolocation-types
|
|
411
|
+
,
|
|
415
412
|
enumerable: false,
|
|
416
413
|
configurable: true
|
|
417
414
|
});
|
|
418
415
|
Object.defineProperty(BackgroundGeolocation, "EVENT_AUTHORIZATION", {
|
|
419
|
-
get: function () { return
|
|
416
|
+
get: function () { return Event.Authorization; },
|
|
420
417
|
enumerable: false,
|
|
421
418
|
configurable: true
|
|
422
419
|
});
|
|
@@ -611,10 +608,10 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
611
608
|
configurable: true
|
|
612
609
|
});
|
|
613
610
|
BackgroundGeolocation.ready = function (config) {
|
|
614
|
-
return NativeModule.ready({ options:
|
|
611
|
+
return NativeModule.ready({ options: config });
|
|
615
612
|
};
|
|
616
613
|
BackgroundGeolocation.reset = function (config) {
|
|
617
|
-
return NativeModule.reset({ options:
|
|
614
|
+
return NativeModule.reset({ options: config });
|
|
618
615
|
};
|
|
619
616
|
BackgroundGeolocation.start = function () {
|
|
620
617
|
return NativeModule.start();
|
|
@@ -632,7 +629,7 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
632
629
|
return NativeModule.startGeofences();
|
|
633
630
|
};
|
|
634
631
|
BackgroundGeolocation.setConfig = function (config) {
|
|
635
|
-
return NativeModule.setConfig({ options:
|
|
632
|
+
return NativeModule.setConfig({ options: config });
|
|
636
633
|
};
|
|
637
634
|
BackgroundGeolocation.getState = function () {
|
|
638
635
|
return NativeModule.getState();
|
|
@@ -656,48 +653,63 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
656
653
|
});
|
|
657
654
|
});
|
|
658
655
|
};
|
|
659
|
-
BackgroundGeolocation.watchPosition = function (onLocation, onError
|
|
660
|
-
var _this = this;
|
|
656
|
+
BackgroundGeolocation.watchPosition = function (options, onLocation, onError) {
|
|
661
657
|
options = options || {};
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
else {
|
|
677
|
-
onLocation(response);
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
return [4 /*yield*/, NativeModule.addListener("watchposition", handler)];
|
|
681
|
-
case 1:
|
|
682
|
-
listener = _a.sent();
|
|
683
|
-
NativeModule.watchPosition({ options: options }).then(function () {
|
|
684
|
-
WATCH_POSITION_SUBSCRIPTIONS.push(listener);
|
|
685
|
-
resolve();
|
|
686
|
-
}).catch(function (error) {
|
|
687
|
-
listener.remove();
|
|
688
|
-
reject(error.message);
|
|
689
|
-
});
|
|
690
|
-
return [2 /*return*/];
|
|
658
|
+
var isRemoved = false;
|
|
659
|
+
var nativeWatchId = null;
|
|
660
|
+
var subscriptionProxy = {
|
|
661
|
+
remove: function () {
|
|
662
|
+
isRemoved = true;
|
|
663
|
+
if (nativeWatchId !== null) {
|
|
664
|
+
var listener = WATCH_POSITION_SUBSCRIPTIONS.get(nativeWatchId);
|
|
665
|
+
if (listener) {
|
|
666
|
+
listener.remove();
|
|
667
|
+
WATCH_POSITION_SUBSCRIPTIONS.delete(nativeWatchId);
|
|
668
|
+
}
|
|
669
|
+
NativeModule.stopWatchPosition({ watchId: nativeWatchId });
|
|
670
|
+
nativeWatchId = null;
|
|
691
671
|
}
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var handler = function (response) {
|
|
675
|
+
if (response.hasOwnProperty("error") && (response.error != null)) {
|
|
676
|
+
if (typeof (onError) === 'function') {
|
|
677
|
+
onError(response.error.code);
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
console.warn('[BackgroundGeolocation watchPosition] DEFAULT ERROR HANDLER. Provide an onError callback to watchPosition to receive this message: ', response.error);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
onLocation(response);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
NativeModule.addListener("watchposition", handler).then(function (listener) {
|
|
688
|
+
NativeModule.watchPosition({ options: options }).then(function (result) {
|
|
689
|
+
nativeWatchId = result.watchId;
|
|
690
|
+
if (isRemoved) {
|
|
691
|
+
// remove() was called before the native async call resolved — honour it now.
|
|
692
|
+
listener.remove();
|
|
693
|
+
NativeModule.stopWatchPosition({ watchId: nativeWatchId });
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
WATCH_POSITION_SUBSCRIPTIONS.set(nativeWatchId, listener);
|
|
697
|
+
}
|
|
698
|
+
}).catch(function () {
|
|
699
|
+
listener.remove();
|
|
692
700
|
});
|
|
693
|
-
});
|
|
701
|
+
});
|
|
702
|
+
return subscriptionProxy;
|
|
694
703
|
};
|
|
695
|
-
BackgroundGeolocation.stopWatchPosition = function () {
|
|
696
|
-
|
|
697
|
-
var
|
|
698
|
-
|
|
704
|
+
BackgroundGeolocation.stopWatchPosition = function (watchId) {
|
|
705
|
+
if (watchId !== undefined) {
|
|
706
|
+
var listener = WATCH_POSITION_SUBSCRIPTIONS.get(watchId);
|
|
707
|
+
if (listener) {
|
|
708
|
+
listener.remove();
|
|
709
|
+
WATCH_POSITION_SUBSCRIPTIONS.delete(watchId);
|
|
710
|
+
}
|
|
711
|
+
NativeModule.stopWatchPosition({ watchId: watchId });
|
|
699
712
|
}
|
|
700
|
-
return NativeModule.stopWatchPosition();
|
|
701
713
|
};
|
|
702
714
|
BackgroundGeolocation.requestPermission = function () {
|
|
703
715
|
return new Promise(function (resolve, reject) {
|
|
@@ -932,55 +944,52 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
932
944
|
};
|
|
933
945
|
/// Event Handling
|
|
934
946
|
///
|
|
935
|
-
BackgroundGeolocation.onLocation = function (
|
|
936
|
-
return BackgroundGeolocation.addListener(
|
|
947
|
+
BackgroundGeolocation.onLocation = function (cb, onError) {
|
|
948
|
+
return BackgroundGeolocation.addListener(Event.Location, cb, onError);
|
|
937
949
|
};
|
|
938
|
-
BackgroundGeolocation.onMotionChange = function (
|
|
939
|
-
return BackgroundGeolocation.addListener(
|
|
950
|
+
BackgroundGeolocation.onMotionChange = function (cb) {
|
|
951
|
+
return BackgroundGeolocation.addListener(Event.MotionChange, cb);
|
|
940
952
|
};
|
|
941
|
-
BackgroundGeolocation.onHttp = function (
|
|
942
|
-
return BackgroundGeolocation.addListener(
|
|
953
|
+
BackgroundGeolocation.onHttp = function (cb) {
|
|
954
|
+
return BackgroundGeolocation.addListener(Event.Http, cb);
|
|
943
955
|
};
|
|
944
|
-
BackgroundGeolocation.onHeartbeat = function (
|
|
945
|
-
return BackgroundGeolocation.addListener(
|
|
956
|
+
BackgroundGeolocation.onHeartbeat = function (cb) {
|
|
957
|
+
return BackgroundGeolocation.addListener(Event.Heartbeat, cb);
|
|
946
958
|
};
|
|
947
|
-
BackgroundGeolocation.onProviderChange = function (
|
|
948
|
-
return BackgroundGeolocation.addListener(
|
|
959
|
+
BackgroundGeolocation.onProviderChange = function (cb) {
|
|
960
|
+
return BackgroundGeolocation.addListener(Event.ProviderChange, cb);
|
|
949
961
|
};
|
|
950
|
-
BackgroundGeolocation.onActivityChange = function (
|
|
951
|
-
return BackgroundGeolocation.addListener(
|
|
962
|
+
BackgroundGeolocation.onActivityChange = function (cb) {
|
|
963
|
+
return BackgroundGeolocation.addListener(Event.ActivityChange, cb);
|
|
952
964
|
};
|
|
953
|
-
BackgroundGeolocation.onGeofence = function (
|
|
954
|
-
return BackgroundGeolocation.addListener(
|
|
965
|
+
BackgroundGeolocation.onGeofence = function (cb) {
|
|
966
|
+
return BackgroundGeolocation.addListener(Event.Geofence, cb);
|
|
955
967
|
};
|
|
956
|
-
BackgroundGeolocation.onGeofencesChange = function (
|
|
957
|
-
return BackgroundGeolocation.addListener(
|
|
968
|
+
BackgroundGeolocation.onGeofencesChange = function (cb) {
|
|
969
|
+
return BackgroundGeolocation.addListener(Event.GeofencesChange, cb);
|
|
958
970
|
};
|
|
959
|
-
BackgroundGeolocation.onSchedule = function (
|
|
960
|
-
return BackgroundGeolocation.addListener(
|
|
971
|
+
BackgroundGeolocation.onSchedule = function (cb) {
|
|
972
|
+
return BackgroundGeolocation.addListener(Event.Schedule, cb);
|
|
961
973
|
};
|
|
962
|
-
BackgroundGeolocation.onEnabledChange = function (
|
|
963
|
-
return BackgroundGeolocation.addListener(
|
|
974
|
+
BackgroundGeolocation.onEnabledChange = function (cb) {
|
|
975
|
+
return BackgroundGeolocation.addListener(Event.EnabledChange, cb);
|
|
964
976
|
};
|
|
965
|
-
BackgroundGeolocation.onConnectivityChange = function (
|
|
966
|
-
return BackgroundGeolocation.addListener(
|
|
977
|
+
BackgroundGeolocation.onConnectivityChange = function (cb) {
|
|
978
|
+
return BackgroundGeolocation.addListener(Event.ConnectivityChange, cb);
|
|
967
979
|
};
|
|
968
|
-
BackgroundGeolocation.onPowerSaveChange = function (
|
|
969
|
-
return BackgroundGeolocation.addListener(
|
|
980
|
+
BackgroundGeolocation.onPowerSaveChange = function (cb) {
|
|
981
|
+
return BackgroundGeolocation.addListener(Event.PowerSaveChange, cb);
|
|
970
982
|
};
|
|
971
|
-
BackgroundGeolocation.onNotificationAction = function (
|
|
972
|
-
return BackgroundGeolocation.addListener(
|
|
983
|
+
BackgroundGeolocation.onNotificationAction = function (cb) {
|
|
984
|
+
return BackgroundGeolocation.addListener("notificationaction", cb);
|
|
973
985
|
};
|
|
974
|
-
BackgroundGeolocation.onAuthorization = function (
|
|
975
|
-
return BackgroundGeolocation.addListener(
|
|
986
|
+
BackgroundGeolocation.onAuthorization = function (cb) {
|
|
987
|
+
return BackgroundGeolocation.addListener(Event.Authorization, cb);
|
|
976
988
|
};
|
|
977
989
|
///
|
|
978
990
|
/// Listen to a plugin event
|
|
979
991
|
///
|
|
980
992
|
BackgroundGeolocation.addListener = function (event, success, failure) {
|
|
981
|
-
if (!Events[event.toUpperCase()]) {
|
|
982
|
-
throw (TAG + "#addListener - Unknown event '" + event + "'");
|
|
983
|
-
}
|
|
984
993
|
var handler = function (response) {
|
|
985
994
|
if (response.hasOwnProperty("value")) {
|
|
986
995
|
response = response.value;
|