Seloka
Seloka

Reputation: 405

Using non ionic-native cordova plugin

i am trying to integrate [This]https://github.com/louisbl/cordova-plugin-locationservices plugin into my ionic 4 app.

since its a non ionic-native plugin, how do i go about calling its functions withing my typescript code?

i have tried using declare var locationservices: any; locationServices.geolocation.getCurrentPosition(geolocationSuccess,[geolocationError],geolocationOptions]);

but i get an error that locationservices is not defined

Upvotes: 0

Views: 245

Answers (1)

Seloka
Seloka

Reputation: 405

so instead of using declare var locationservices: any i used declare var cordova: any;

`declare var cordova: any;
cordova.plugins.locationServices.geolocation.getCurrentPosition(
      position => {
         console.log(position)
      }
    );`

NB:the code will always result to undefined when tested on a browser, it needs to be tested on a device

Upvotes: 1

Related Questions