History saving and retrieving in iphone - ios

I have an application in which a user can upload recorded audio or video or picks an existing from library, pictures clicked or picked. I need that user to be able to view, say the last 50 uploaded items, for which I have made a screen called "Recent Additions" which has a table view which will be populated with those 50 items.
What options do I have?
I think that I have to add a local storage for it... If yes, how?
Can NSUserDefaults can help me?
When the user records/clicks/picks any asset, a URL is generated by system which I also use for uploading. Will the same URL I would need for saving that item in history?

NSUserDefaults won't help you. That's meant for populating text fields and small tasks-- certainly not writing to disk.
To save a video or photo to your the iPhone out of app, you could just use UIActivityViewController and save to camera role after making an NSData instance. That's only if you are supporting iOS 6 and higher, however.
If you could want to save the media to the device's camera roll, you could make an NSData instance, use UIImagePNGRepresentation (if it's an image), make an instance of UIImage with the data, and finally use UIImageWriteToSavedPhotosAlbum.
For in-app writing to disk, check out Apple's docs on NSCoding and NSFileManager.

Related

Objective c - How to check if the photo metadata has been changed

I am developing in-House iOS app with objective-c for capturing images and I'm depending on photos metadata to get the correct locations and dates, but the new iOS versions allow the user to adjusting and changing the whole photo information, and our field staff able to changing the photo metadata with fake details.
The only ways that can protect the informations:
1- How to check the photo if metadata has changed or not, and refuse the modified photo.?
2- It possible to create configuration file to make all photos with read-only?
The photo library, accessible through the Photos app, belongs to the user — not to you. So if you don't want the user to have normal powers over these photos, then don't store them in the user's photo library.
With other objects on iOS (I'm thinking of contacts in particular) you can store metadata of your own in Apple's database. I don't think that's the case with photos, sorry.
You could perhaps require your users take the photo in your app and store the location in a database of your own. You might be able to store the photo in the photos database if that's something you want.

In a iOS app, how to share photos with another iCloud user without sharing the full UIImage, having iCloud handle this?

Many thanks for your help. I am developing an application in Swift for iOS 12+, using Xcode 11. It is a travelling application, and has a "Trip" Core Data entity. Each trip can hold notes, and I would like to use this library, ZSSRichTextEditor, to let the user edit and store the notes in rich text, optionally containing images. As it is, the library can insert images as links on the internet, or from the user Photos library. When using the latter option, the library takes the full UIImage and encodes it as base64, then it inserts it in the WKWebView that the library uses under the hood. Here comes my problem. I would like to let users of my app share trips between them, but I would like to not include the full pictures in the shared trip file, but references to the iCloud photo. Can somebody suggest a possible implementation ? Many thanks.

React Native, storing images in users gallery without compression

I am developing an App that verifies images based on their hash. I hash the images using this library "react-native-fetch-blob".
I store all the images taken inside the app, I am trying to allow users to be able to share the original uncompressed image.
Problem: When using React-Native Camera roll or React native Share to save the image to my local gallery, compression is performed which changes the hash of the image if I recalculate it.
What I want to do, is to be able to save the image to the users local gallery without compressing the photo?
Any help would be very appreciated. :)
I have run tests retrieving the photos back into the app (from the user's normal gallery) using React-Native-Image-Picker; However, I believe that also forms some compression on the image. I have also used react-native-fetch-blob to copy the photo from the user photo gallery back into the app.
Can provide code I used to generate the below results if anyone needs that.
Hash Results - from Image Picker
camera roll save
10c30a42ead3636a8fd8cfd1eb6952db9f8bbb97fbbdccf96060b67f27be0766
fileSize: 591635,
React-Native share save image
cf799ba599e65a42905cb25fabc0150286ee923113da2af21ad7bb2a650bb86d
fileSize: 603288
Expected
Hash0802368f14296c4d6750a4fc853cda68de67b8e31adf16f38b0eabb7e8b28d0a
Thanks Again
Solved issue on react-native-camera-roll. Issue was stripping of meta-data on IOS side.
https://github.com/react-native-community/react-native-cameraroll/issues/125

Capture a image and know the location of that image from where it was captured in iOS

I am going to design a app in iOS in which i have a functionality, whenever i capture a image from an iOS device that "image should not be saved in the camera roll" and "i need to know the exact location from where the image was captured that is street address, country, etc,.....". Any help would be appreciated.
Thanks in advance.
Exif Data is the partially hidden part of a photo file that most people don't think about when they upload a photo to a service like Dropbox or send a photo to a friend. This EXIF data includes the camera model you are using, basic settings of the camera when the picture was taken, the photo resolution and, if your camera has GPS, the location where the photo was taken.
You can extract the Exif data from image file (Get Exif data from UIImage - UIImagePickerController).
You can also view that data with Preview app on mac. To see go to Preview and click for info for image their you get GPS data for file.
It is correct that the iphone(ipad, etc, i'll just call it iphone from now on) strips exif data. This is also not a bug on the iphone but actually a feature.
One of the main reasons android users don't like the iphone and iphone users don't like the androids, is because the iphone is very limited (in terms of freedom to change, alter, etc). You can not just run downloaded apps, have limited access to settings, etc.
This is because the apple strategy is to create a fail-safe product. "If you can not do strange things, strange things will not happen".It tries to protect the user in every way imaginable. It also protects the user when uploading images. In the exif there may be data that can hurt the users privacy. Things like GPS coordinates, but even a timestamp can hurt a user (imagine you uploading a beach picture with a timestamp from a moment you reported in sick with the boss).
So basically it is a safety meassure to strip all exif data. Myself and a lot of other people do not agree with this strategy, but there is nothing we can do about it unfortunately.
The solution
Update: This does not work.
Luckily you can get around this problem. Javascript comes to the rescue. With javascript you can read the exif data and send it with you photo by adding some extra POST data.
please note: this solution was presented to me by another developer and is not yet tested.

How should I store images if content will need to be synced with iCloud

I'm in the process of enabling iCloud support on my app and have encountered an issue. Within my content object that users create, they can choose a picture for their object. Currently I'm storing that image as binary data in coredata and am using the external storage option because in testing i've found that images can range from 1-3mb in size.
NOTE: I'm saving the data itself instead of a reference to the selected image so that a user cannot accidentally remove an image asset that they have added to my app's content object by removing an image from their photostream or camera roll.
While reading Apple's information on iCloud they mention not to store large downloaded data files. (source)
Given my current data structure seems to work without iCloud, how should I modify it so that I can incorporate iCloud for data syncing across devices? If Apple suggests not syncing large files, how should that data be sent between devices?
It depends on where the users choose these pictures from. Basically, if you don't send the image via iCloud, is there any other way you could get it?
If they come from some online source and they could be downloaded from there again, then you'd fall into the "large downloaded data files" category. Pass the URL or other details on how to re-do the download from one device to another and download again as needed.
If they come from some other source that's not readily available on another device (e.g. the user selected a photo from their camera roll), go ahead and pass it between devices as is. That would be more like a user document or data, not something you can re-download on demand.

Resources