@capgo/background-geolocation 8.0.35 → 8.0.37

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.
@@ -14,6 +14,7 @@ import android.location.LocationManager;
14
14
  import android.media.MediaPlayer;
15
15
  import android.os.Binder;
16
16
  import android.os.Build;
17
+ import android.os.Bundle;
17
18
  import android.os.Handler;
18
19
  import android.os.IBinder;
19
20
  import android.os.Looper;
@@ -165,6 +166,41 @@ public class BackgroundGeolocationService extends Service {
165
166
  }
166
167
  }
167
168
 
169
+ private void handleLocationChanged(android.location.Location location) {
170
+ startWatchdog();
171
+ if (mediaPlayer != null) {
172
+ double[] point = { location.getLongitude(), location.getLatitude() };
173
+ var offRoute = distancePointToRoute(point) > distanceThreshold;
174
+ if (offRoute == true && isOffRoute == false) {
175
+ mediaPlayer.start();
176
+ }
177
+ isOffRoute = offRoute;
178
+ }
179
+ Intent intent = new Intent(ACTION_BROADCAST);
180
+ intent.putExtra("location", location);
181
+ intent.putExtra("id", callbackId);
182
+ LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
183
+ }
184
+
185
+ // Android API < 30 requires these legacy callbacks to be implemented.
186
+ static LocationListener createLocationListener(final BackgroundGeolocationService service) {
187
+ return new LocationListener() {
188
+ @Override
189
+ public void onLocationChanged(android.location.Location location) {
190
+ service.handleLocationChanged(location);
191
+ }
192
+
193
+ @Override
194
+ public void onStatusChanged(String provider, int status, Bundle extras) {}
195
+
196
+ @Override
197
+ public void onProviderEnabled(String provider) {}
198
+
199
+ @Override
200
+ public void onProviderDisabled(String provider) {}
201
+ };
202
+ }
203
+
168
204
  // Handles requests from the activity.
169
205
  public class LocalBinder extends Binder {
170
206
 
@@ -175,21 +211,7 @@ public class BackgroundGeolocationService extends Service {
175
211
  callbackId = id;
176
212
  currentDistanceFilter = distanceFilter;
177
213
 
178
- locationCallback = (location) -> {
179
- startWatchdog();
180
- if (mediaPlayer != null) {
181
- double[] point = { location.getLongitude(), location.getLatitude() };
182
- var offRoute = distancePointToRoute(point) > distanceThreshold;
183
- if (offRoute == true && isOffRoute == false) {
184
- mediaPlayer.start();
185
- }
186
- isOffRoute = offRoute;
187
- }
188
- Intent intent = new Intent(ACTION_BROADCAST);
189
- intent.putExtra("location", location);
190
- intent.putExtra("id", callbackId);
191
- LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);
192
- };
214
+ locationCallback = createLocationListener(BackgroundGeolocationService.this);
193
215
 
194
216
  try {
195
217
  client.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, distanceFilter, locationCallback);
@@ -38,7 +38,7 @@ func formatLocation(_ location: CLLocation) -> PluginCallResultData {
38
38
  @objc(BackgroundGeolocation)
39
39
  // swiftlint:disable:next type_body_length
40
40
  public class BackgroundGeolocation: CAPPlugin, CLLocationManagerDelegate, CAPBridgedPlugin {
41
- private let pluginVersion: String = "8.0.35"
41
+ private let pluginVersion: String = "8.0.37"
42
42
  public let identifier = "BackgroundGeolocationPlugin"
43
43
  public let jsName = "BackgroundGeolocation"
44
44
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/background-geolocation",
3
- "version": "8.0.35",
3
+ "version": "8.0.37",
4
4
  "description": "Accurate background geolocation and native geofencing for Capacitor apps on iOS and Android.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",