Skip to content

Fix iOS Safari geolocation re-prompting on reload#69

Merged
yepzdk merged 1 commit intodevelopfrom
feature/fix-ios-safari-geolocation-reprompt
Mar 3, 2026
Merged

Fix iOS Safari geolocation re-prompting on reload#69
yepzdk merged 1 commit intodevelopfrom
feature/fix-ios-safari-geolocation-reprompt

Conversation

@yepzdk
Copy link
Contributor

@yepzdk yepzdk commented Feb 23, 2026

Summary

On iOS Safari, users are re-prompted for geolocation permission after every page reload. This is caused by using getCurrentPosition() inside a setInterval() — each call triggers a fresh permission prompt on iOS Safari. Additionally, navigator.permissions.query() is unsupported on iOS Safari, causing the permission banner logic to fail silently.

Changes

  • Replace getCurrentPosition + setInterval pattern with watchPosition, which triggers only one permission prompt and continuously delivers position updates
  • Guard navigator.permissions.query() with a feature check for iOS Safari compatibility
  • Add error callbacks for PERMISSION_DENIED, POSITION_UNAVAILABLE, and TIMEOUT
  • Change permission banner condition from !== "granted" to === "denied" so the banner doesn't show for the "prompt" state (let watchPosition trigger the actual prompt first)
  • Fix typo in Danish text: "angang" → "adgang"

Files Changed

  • src/App.jsx — Replaced geolocation logic (all changes confined to this file)
  • CHANGELOG.md — Updated under [Unreleased]

Test Plan

  • Verify location updates work in a desktop browser and the map shows the user's position
  • On iOS Safari (physical device): grant permission, reload the page, confirm no re-prompt appears
  • Test permission denial flow: deny location, verify info banner appears with navigation help link
  • Test timeout/unavailable scenarios show appropriate error messages

@yepzdk yepzdk force-pushed the feature/fix-ios-safari-geolocation-reprompt branch from 953a4d4 to 57e545c Compare March 2, 2026 09:30
iOS Safari re-prompts geolocation permission on every getCurrentPosition
call after a page reload. Replace the getCurrentPosition + setInterval
pattern with watchPosition which triggers only one permission prompt and
continuously delivers updates.

Also guard navigator.permissions.query() which is unsupported on iOS
Safari, and add error callbacks for permission denied, position
unavailable, and timeout scenarios.
@yepzdk yepzdk force-pushed the feature/fix-ios-safari-geolocation-reprompt branch from 57e545c to e151b21 Compare March 2, 2026 11:45
@yepzdk yepzdk requested a review from rimi-itk March 2, 2026 14:34
@yepzdk yepzdk merged commit 35c480f into develop Mar 3, 2026
5 checks passed
@yepzdk yepzdk deleted the feature/fix-ios-safari-geolocation-reprompt branch March 3, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants