I had a similar issue. I also tried to do this exact code but Safari (nor Safari for iOS) support the Permissions API.

However, I was able to do a workaround by using the Navigator API.

Try using navigator.geolocation.getCurrentPosition(success, error, options); if it triggers the success callback, the user has granted access to its location.

Related Query

More Query from same tag