Skip to content

Keep capture GPS out of iOS photos unless includeLocation is set - #13

Merged
simonhamp merged 1 commit into
mainfrom
fix/ios-camera-location-opt-in
Oct 22, 2026
Merged

simonhamp merged 1 commit into
mainfrom
fix/ios-camera-location-opt-in

Conversation

@simonhamp

Copy link
Copy Markdown
Member

Follow-up to #6.

The iOS camera delegate now writes the picker's mediaMetadata into the saved JPEG so Exif survives. Only the synthesised GPS was gated on includeLocation. If the capture metadata already had a GPS dictionary, because the app holds location permission for some other reason, it went into the file and into the PhotoTaken payload without the caller opting in. Before #6 the file was re-encoded from a bare UIImage, so it never had location.

Changes:

  • When includeLocation is false, the GPS dictionary is removed from the properties before the JPEG is written. The rest of the Exif is kept, so takenAt still works.
  • finishPhoto takes the flag and only sets latitude/longitude when it's true.
  • The README now says iOS camera captures carry no location unless you opt in. Android isn't affected: there the system camera app decides whether GPS goes in the file, and that was already the case before Preserve photo capture date and GPS location #6.

I only parse-checked the Swift (swiftc -parse) and haven't run it on a device. Worth testing a capture with includeLocation off in an app that already has location permission, then confirming the file has no GPS tags and the event has no coordinates.

🤖 Generated with Claude Code

Since #6 the camera delegate copies the picker's media metadata into the
saved JPEG and reads coordinates from it for the PhotoTaken payload. If the
app already has location permission for another reason, that metadata can
contain a GPS dictionary, which then ended up in the file and the event even
with includeLocation false.

Strip the GPS dictionary before writing when the caller hasn't opted in, and
only add latitude/longitude to the payload when they have. The README now
says this explicitly for iOS camera captures.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@simonhamp
simonhamp merged commit 931c690 into main Oct 22, 2026
2 checks passed
@simonhamp
simonhamp deleted the fix/ios-camera-location-opt-in branch October 22, 2026 14:46
simonhamp added a commit to sonalidudhia/mobile-camera that referenced this pull request Oct 22, 2026
NativePHP#17 landed on main with a smaller version of this fix, so the three
picker call sites conflicted. This keeps CameraPresenter and drops
NativePHP#17's topViewController helper, because CameraPresenter also waits
for a sheet that is still closing before it presents. Everything else
from main, including NativePHP#13, comes through unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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