transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
656 stars 277 forks source link

[RELEASE] 4.14.1 #1415

Closed christocracy closed 8 months ago

christocracy commented 8 months ago

4.14.1 — 2023-08-24

BacckgroundGeolocation.onHeartbeat(async (event) => {
  console.log("[onHeartbeat] $event");
  // First register a background-task.
  const taskId = await BackgroundGeolocation.startBackgroundTask();
  try {
    // Now you're free to perform long-running tasks, such as getCurrentPosition()
    const location = await BackgroundGeolocation.getCurrentPosition({
      samples: 3,
      timeout: 30,
      extras: {
        "event": "heartbeat"
      }
    });
    console.log("[onHeartbeat] location:", $location);
  } catch(error) {
    console.log("[getCurrentPosition] ERROR:", error);
  }
  // Be sure to singal completion of your background-task:
  BackgroundGeolocation.stopBackgroundTask(taskId);
});