Welcome to the 2. day of the Capacitor Crash Course
Links:
Commands used:
1 |
npm install @ionic/pwa-elements |
Code used in this lesson:
src/main.ts
1 2 3 4 |
import { defineCustomElements } from '@ionic/pwa-elements/loader'; // Call the element loader after the platform has been bootstrapped defineCustomElements(window); |
src/app/home/home.page.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import { Plugins } from '@capacitor/core'; const { Browser, Geolocation } = Plugins; async getCurrentPosition() { const coordinates = await Geolocation.getCurrentPosition(); console.log('Current', coordinates); const wait = Geolocation.watchPosition({}, (position, err) => { console.log('err: ', err); console.log('Changed: ', position); }); } openBrowser() { Browser.open({url: 'https://ionicacademy.com'}); } |