Fix iOS Safari geolocation re-prompting on reload#69
Open
Conversation
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
…-geolocation-reprompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On iOS Safari, users are re-prompted for geolocation permission after every page reload. This is caused by using
getCurrentPosition()inside asetInterval()— 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
getCurrentPosition+setIntervalpattern withwatchPosition, which triggers only one permission prompt and continuously delivers position updatesnavigator.permissions.query()with a feature check for iOS Safari compatibilityPERMISSION_DENIED,POSITION_UNAVAILABLE, andTIMEOUT!== "granted"to=== "denied"so the banner doesn't show for the "prompt" state (letwatchPositiontrigger the actual prompt first)Files Changed
src/App.jsx— Replaced geolocation logic (all changes confined to this file)CHANGELOG.md— Updated under[Unreleased]Test Plan