Background Geolocation isn't a Observable

I need Implement a Background Geolocation in my app. I acess this ionic documentation, there shows the code below:

this.backgroundGeolocation.configure(config)
  .subscribe((location: BackgroundGeolocationResponse) => {

    console.log(location);

    // IMPORTANT:  You must execute the finish method here to inform the native plugin that you're finished,
    // and the background-task may be completed.  You must do this regardless if your HTTP request is successful or not.
    // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
    this.backgroundGeolocation.finish(); // FOR IOS ONLY

  });

When I used this code in my app, my ts-lint accuse the configure(config) method is a Promise<any> and not a Observable, so, I cant use subscribe. I switched subscribe for then. But when I run, shows this error below:

ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
    at BackgroundGeolocation.configure (vendor.js:82333)
// error below ommited

Someone can help me?

For ionic 3 you should user :

you can check my example here :

1 Like

Make sure yo are following the ionic v3 docs and remove ionic native and install using the command

npm install --save @ionic-native/background-geolocation@4

Thanks so much! Your repository saved my life!! In the Ionic v3 documentation background geolocation says that i need install the last version of the plugin and the version 4 of the background geolocation npm.

When I installed the same error occurred, looking your repository I saw that the versions of the plugin is 2.2.5 and the background geolocation npm is 3.12.1.

So, I installed this version of the plugin and version 3.14.0 of the background geolocation, its works fine now =) Thanks again!

Following the ionic v3 docs, I receive the same error. Looking the @Jalvarez05 repository I saw that the versions was different, when I installed the version plugin 2.2.5 and the version background geolocation npm 3.14.0 worked fine. Thanks by reply my post =)

I’ve added a new example on my repo :

I’m trying to do the next :

If you can help me, tell me please.

THank you

1 Like

Thanks for your effort, but i notice in your package.json you are not using @ionic-native/background-geolocation@4
you are using “@ionic-native/background-geolocation”: “^3.12.1”

is there any chance it will work with ionic-native/background-geolocation@4 ?

For a while, i think so its not possible. That worries me, cause i received a Google email saying that their only accept apps with 64 bits from 1 August, and i dont know if the @ionic-native/background-geolocation”: “^3.12.1 is in 64 bits.

I’ve tried with ionic-native/background-geolocation@4 , but it never worked , for this reason i’ve used another version … Here is another complete example , check it :

1 Like

Its not working with ionic-native/background-geolocation@4
how we can report this issue to ionic team ?

Really I don’t know, but from Ionic 4 is release, i’ve gotten errors using ionic 3.9.2 with the new way to import plugins : adding /ngx on the end like official documentation.

after adding @ionic-native/background-geolocation@3.12.1 getting following error. can someone help me to sort out this error

uninstall your background geolocation plugin and use this commands:

ionic cordova plugin add cordova-plugin-mauron85-background-geolocation@2.2.5
$ npm install --save @ionic-native/background-geolocation@3

You are a savior!! Thank you very much. You just made my day!

Is it crashing on Android 9. Has someone ever solved this problem? And I can’t using the version “cordova-plugin-mauron85-background-geolocation”: "^3.0.0-alpha.50 on ionic 3.

Try this code

this.backgroundGeolocation.configure(config).then((location) => { this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe(
(location: BackgroundGeolocationResponse) => {
console.log(‘BackgroundGeolocationResponse’, location);
}, (err) => {
console.log(err);
})