Geolocation

The final plugin we are going to take a look at is the Geolocation plugin, which helps to fetch the coordinates of the device.

You can know more about the plugin from here: https://github.com/apache/cordova-plugin-geolocation and https://ionicframework.com/docs/native/geolocation/.

First, scaffold a new blank app for the Geolocation plugin:

ionic start -a "Example 20" -i app.example.twenty example20 blank --v2

Once the app is scaffolded, cd into the example20 folder. Now we will add the Geolocation plugin, run the following command:

ionic plugin add cordova-plugin-geolocation

Next, run the following command to add the Ionic Native module:

npm install --save @ionic-native/geolocation

Now, we register the provider. Update ...

Get Learning Ionic - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.