I have an application that is written in Monotouch and one function that it offers is taking photos that are then synchronized back to a Sybase Sql Anywhere database on our server. This mechanism is working fine on the Windows version of our application, but on iOS we have hit technical issues pertaining to saving the photos in the Sybase Ultralite database on the iPad or iPhone. Very briefly, the photos are saving correctly if we set the resolution to VERY low on an iPhone, but failing if the resolution is higher. The issue is related to the size of the image data that is being saved. On an iPad, the photos are generally larger than those taken with an iPhone, so saving to the database is failing more often on iPad than iPhone.
Anyway, that is just some background to our situation and the actual Ultralite issue is not the focus of this question. What I am looking for here is alternative solutions (Objective-C or Monotouch) for providing this functionality. I immediately think about saving to a local database and then replicating the photo data back to the server because I have a lot of experience with database replication. But maybe there is a better way of solving this?
The solution must allow the application to:
- Save a photo so that it is available locally (even after shutdown of the application or restart of the device)
- Must allow photos to taken and saved offline, because an internet connection is not always available.
- Either synchronize the image data back to the server database or synchronize a URL back that the application in the back-office can retrieve the photo. Obviously, at the point of synchronization the application must be online.
Can anyone suggest solutions or API’s that might allow me to provide this functionality without having to synchronize the image data? I am thinking along the lines of maybe saving the image to the cloud and then synchronizing only a URL that can be used in the back-office to retrieve the photo. Any suggestions?
From what you have wrote, I might suggest that you do not correctly persist images on the iOS devices. The memory on them is very limited and keeping batches of HR images in RAM will result in memory warnings and application crashes. You should consider using
CoreDatato store the local links to the images that are being saved to disk. I presume, you are familiar withUIImagePickerControllerdelegate callbacks that allow you to retrieve your UIImage and save it to your Application’s Documents directory, so I’m omitting it. I’m not sure what do you mean by “Must allow photos to taken and saved offline”, as neitherUIImagePickerControllernorAVFoundationare not dependent on the Internet connection. So in order to save images offline, just kinda use one of these (UIImagePickerControlleris more preferable, if you do not need to show any custom UI on your camera screen, and much easier to begin working with). If you need to synchronize multiple images at the same time, you should show a UIProgressBar and upload images in a queue, whereas each REST request you’re making is a multi-part data request used to upload a single image at a time. This way you will not have any issues with memory management, you can also use the HR quality for the taken images, there’s no need to use the lowest one. For HTTP connectivity you might want to consider using ASIHTTPRequest as it’s plain, very simple to work with and might save you some time with multi-part requests.