backgroundGeoLocation is returning ok but I couldn't get the location!

Guys I am making an app which has tracking ability , anyway I am using this plugin :

I used this code to get the location :

const config: BackgroundGeolocationConfig = {
  desiredAccuracy: 50,
  stationaryRadius: 1,
  distanceFilter: 1,
  debug: true, //  enable this hear sounds for background-geolocation life-cycle.
  stopOnTerminate: false, // enable this to clear background location settings when the app terminates

  .then((location: BackgroundGeolocationResponse) => {
    console.log("Here you should see the location");
    console.log("Here you should see the End location");

// start recording location

so the problem is that when I tried to run it on an android device I got this output

[INFO:CONSOLE(762)] "Here you should see the location"
[INFO:CONSOLE(764)] "undefined"
[INFO:CONSOLE(765)] "Here you should see the End location"

how can I get the location ?! , from what I understood location.longitude should show the longitude but it is not , and location is a BackgroundGeolocationResponse but it is not it is showing “ok” , please guys help me I am stuck for two days now on the same issue.

guys please help I’m stuck

I tried to change the versions of the plugin but I get an error (the plugin is not installed when I run it on android device)

I had a nightmare with this plugin since upgrading to Ionic 4. Ultimately I just used the latest version of the plugin (3.0.3) and used the Cordova plugin directly and it worked that way, or at least it does on my old Samsung Galaxy S5. My new Huawei P30 kills the process as soon as the screen goes to sleep. I’ve tried all the steps listed at but that doesn’t work for me.

thank you for your reply I almost gave up , can you please explain how you used the plugin directly, it is not clear to me ?

Yeah, no problem. I had trouble with it too but it’s actually really easy.

So on this page it tells you to install two things, just install the first “ionic cordova plugin add @mauron85/cordova-plugin-background-geolocation”. Then in your page’s ts file put “declare let BackgroundGeolocation: any;” at the top near the imports then you can use the exact same example code on the plugin’s page

1 Like

i am also having the same issue in android 6 huawei ALE-21 mobile its always return “OK” instead of location return.any one can help ? i followed the provided by resource in git link but nothing show positive result?

Notice the import - “BackgroundGeolocationEvents”

import { BackgroundGeolocation, BackgroundGeolocationConfig, BackgroundGeolocationResponse, BackgroundGeolocationEvents, BackgroundGeolocationAccuracy } from '@ionic-native/background-geolocation';

      (location: BackgroundGeolocationResponse) => {
        console.log("backgroundGeolocation config response", location);
          .subscribe((location: BackgroundGeolocationResponse) => {
            console.log("backgroundGeolocation event response", location);
        this.backgroundGeolocation.finish(); // FOR IOS ONLY