Advice about adding GPS location to in-app captured image

Firstly, hi everyone. Is a pleasure to ask the first question in this forum for me.

I have a very uncommon (at least, that is what appears to be) case in our app. We have built a system that allows the end user to capture multiple images in-app and we send them to our servers.

Actually, we need these arrays of images to be stored safely in the users' device, and I have thought about Core Data or FileManager for that purpose. I want to know which is the best way to make this happen (as more difficult is to edit the image, better).

My question is: I have been able to add the GPS information to a PHAssetCreationRequest, and save that to the Gallery of the phone, but I am not able to save that information to the FileManager. How should I add the GPS data?

Accepted Reply

Several questions here.

we need these arrays of images to be stored safely in the users' device

You could:

  • save file names in UserDefaults
  • save the files themselves as files of the app.
  • The files will be saved in the app sandbox, so not directly accessible from other apps

.

How should I add the GPS data?

  • With the previous solution, you could concatenate the image name with GPS location, separated by a custom separator (as #$#) and use it as file name. Separator will ease parsing later.
  • To retrieve an image:
    • retrieve file name from userDefaults
    • load the file to retrieve image
    • split a name in 2 parts with the separator : the first part of the split is the image name and the second its GPS

Hope that helps.

  • Okay Claude, thanks for your response. We will check and for sure it helps a lot.

Add a Comment

Replies

Several questions here.

we need these arrays of images to be stored safely in the users' device

You could:

  • save file names in UserDefaults
  • save the files themselves as files of the app.
  • The files will be saved in the app sandbox, so not directly accessible from other apps

.

How should I add the GPS data?

  • With the previous solution, you could concatenate the image name with GPS location, separated by a custom separator (as #$#) and use it as file name. Separator will ease parsing later.
  • To retrieve an image:
    • retrieve file name from userDefaults
    • load the file to retrieve image
    • split a name in 2 parts with the separator : the first part of the split is the image name and the second its GPS

Hope that helps.

  • Okay Claude, thanks for your response. We will check and for sure it helps a lot.

Add a Comment

Add EXIF metadata to the image as you save it.