Skip to content

Fix iOS Safari geolocation re-prompting on reload#69

Open
yepzdk wants to merge 4 commits intodevelopfrom
feature/fix-ios-safari-geolocation-reprompt
Open

Fix iOS Safari geolocation re-prompting on reload#69
yepzdk wants to merge 4 commits 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

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.
- Fix 8 security vulnerabilities (vite, ajv, js-yaml CVEs)
- Migrate ESLint v8 to v9 with flat config (eslint.config.mjs)
- Update React 19.0.0 to 19.2.4, Prettier 2.x to 3.x
- Remove unused Babel presets/plugins and .babelrc (CRA leftovers)
- Remove unused @tailwindcss/line-clamp
- Update browserslist database
- Format src/index.css for Prettier 3 (changed font-family wrapping)
- Audit only production deps (--omit=dev) since remaining minimatch
  vulnerabilities are in dev-only transitive dependencies
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.

1 participant