Hi
I am trying to get the location of the user in my PWA on iOS (iPhone) - Safari/Chrome
const position = await Plugins.Geolocation.getCurrentPosition();
The function is not delivering the location which is a pity, because debugging is a bit hard (I am using toast message - sadly).
I also tried trough
navigator.geolocation.getCurrentPosition((position) => {
With same results -> nothing.
Does anyone have seen this issue or has been able to obtain current position in iOS PWA succesfully?
Working flawlessly on Android Tablet, and Chrome on PC.
Thanks
Tom
hi @Tommertom ,
I had same problem with you. This is how I solved it.
- Make sure you are using the https:// address, (ionic serve/PWA) in http:// will not have permission to get the location access.
- I check the web ssl certificate information compatibility with apple products, yes they are kinda strict about this, I’ve found they sometimes wouldn’t accept self signed web ssl certificate.
if it still not working… (yes, mine is still not working after those two points)
- Update you Capacitor using v.3 beta (at the time I wrote this).
before:
import { Plugins } from "@capacitor/core";
const { Geolocation } = Plugins;
after:
import { Geolocation, Position } from '@capacitor/geolocation';
After that lines, the rest of the (geolocation) code is no need to be changed at all.
I follow a tutorial from here:
start-build-deploy-your-first-capacitor3-pwa-with-ionic
hope it helps.
Regards,
Martin
Thx!
Will try and will revert in due course