transistorsoft / cordova-background-geolocation-SampleApp

Cordova Background Geolocation Sample Application
https://www.transistorsoft.com/shop/products/cordova-background-geolocation
MIT License
122 stars 78 forks source link

How can we post a mobile latitude and longitude to our server? #116

Open KartikSomsale opened 4 years ago

KartikSomsale commented 4 years ago

Hi, I have user onLocation event for fetching latest location details storing data into server. But I am not able to store it into Database.

private configureBackgroundGeolocation() {
    BackgroundGeolocation.onLocation(location => {
BackgroundGeolocation.startBackgroundTask().then((taskId) => {
  this.http.get(Constants.url+"admin/storeToken/Locaion"+coords.latitude+"-"+coords.longitude)
      .subscribe(response => {
console.log(response);     
      })
})
    },error => {
    });
    BackgroundGeolocation.ready({
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,  // <-- highest possible accuracy
      distanceFilter: 10,
      stopTimeout:10,
      foregroundService: true,
      stopOnTerminate: false,
      heartbeatInterval: 60,
      autoSync:true,
      autoSyncThreshold: 0,
      debug: true,
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE
    }, (state) => {
      if (!state.enabled) {
        BackgroundGeolocation.start();
      }
    });
  }
christocracy commented 4 years ago

Please use syntax highlighting. It's engaged by surrounding your code in 3 backticks + optional language:

let foo = "bar";