Ionic 3 background geolocation not working


I am trying to track when the app is in background and to save latitude and longitude through java api service but i am unable to save the coordinates when app is in background. can we track app in background and call java api?

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

constructor(private backgroundGeolocation: BackgroundGeolocation) { }


const config: BackgroundGeolocationConfig = {
            desiredAccuracy: 10,
            stationaryRadius: 20,
            distanceFilter: 30,
            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(() => {

    this.backgroundGeolocation.on('location').subscribe((location: BackgroundGeolocationResponse) => {

      // 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 operations are 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


// start recording location

// If you wish to turn OFF background-tracking, call the #stop method.