How to use cordova plugins with ionic 2 and ts?

Hi,
I’m starting to deal with ionic 2 with typescript. I’d like to add this plugin

ionic plugin add cordova-plugin-geolocation

but typescript complain for this code

let watch = Geolocation.watchPosition();
    watch.subscribe((data) => {
     //data.coords.latitude
     //data.coords.longitude
     console.log(data)
   });

because the lack of missing type, i’ve tried with this Geolocation: any; but doesn’t work

I’m new of typescript. There is a guide/example/tutorial on how to do that?

Many thanks

I would look at ionic-native.

yep just added via npm install and
import {Geolocation} from ‘ionic-native’;

it works!

1 Like