Reputation: 353
I'm trying to import a cordova plugin (https://www.npmjs.com/package/cordova-plugin-mauron85-background-geolocation). I imported it:
import {BackgroundGeolocation} from 'ionic-native';
and called it:
BackgroundGeolocation.configure(callbackFn, failureFn, {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
interval: 60000
});
But this throws me an error: Supplied parameters do not match any signature of call target... I know what this error means but this is an example from docs...
Upvotes: 0
Views: 323
Reputation: 4162
@Patrick1870, if you are using ionic-native background geolocation, configure method will return a promise. Your syntax should be as follows.
import {BackgroundGeolocation} from 'ionic-native';
let backgroundOptions = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
locationTimeout: 60000 //interval is renamed to locationTimeout
};
BackgroundGeolocation.configure(backgroundOptions).then((location) => {
console.log("location", location)
}).catch((err) => console.log("Error ", err));
If you directly using the plugin without ionic-native, you have to use it as
declare var backgroundGeolocation: any;
let backgroundOptions = {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
locationTimeout: 60000 //interval is renamed to locationTimeout
};
backgroundGeolocation.configure((location) => {
console.log(location);
},(err) => {
console.log("error on background Geolocation ", err);
}, backgroundOptions);
Upvotes: 1