3
votes

I have tried follow documentation plugin location accuracy ionic location accurary and copy paste code in there in a new fresh installer ionic 3

install plugin :

ionic cordova plugin add cordova-plugin-request-location-accuracy npm install @ionic-native/location-accuracy

import in app.module.ts and top component

import { LocationAccuracy } from '@ionic-native/location-accuracy/ngx';

constructor(private locationAccuracy: LocationAccuracy) { }

button click methode

this.locationAccuracy.canRequest().then((canRequest: boolean) => {

 if(canRequest) {    this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(
  () => console.log('Request successful'),
  error => console.log('Error requesting location permissions', error)
  );
  }

});

but get an error :

TypeError: Object(...) is not a function at LocationAccuracy.canRequest (http://localhost:8100/build/vendor.js:79864:133)

what is the solution?

3
same issue for me , no work around - Anuj

3 Answers

3
votes

It looks like you installed the plugin for Ionic 4. I did the same.

You just need to install the correct plugin with this:

$ npm install --save @ionic-native/location-accuracy@4

and the import statement is actually

import { LocationAccuracy } from '@ionic-native/location-accuracy';

Here is the ionic 3 documentation

1
votes

this is the correct plugin version for ionic 3, work for me:

npm install --save @ionic-native/location-accuracy@4

0
votes

For my experience this only works in ionic 4. I have a ionic 4 App my self with the Location accuracy in there and it works perfectly fine. This wasn't there in ionic 3.